Skip to content

Commit 3c13d27

Browse files
author
Cyril Mizzi
committed
Merge branch 'f-test'
* f-test: (22 commits) updates gitignore fixes GraphQLTest fixes model transformer sorter fixes ModelTransformerTest prevent using loadRoutesFrom method (service) fixes mutation NodeEloquentGenerator syntax mistake updates composer.json updates composer.json adds .travis.yml adds GraphQLTest::testMutation test fixes trailing ending spaces adds Mutation NodeEloquentGenerator test adds query node(s) eloquent generator tests fixes EloquentModel trait adds FieldTransformerTest fixes EloquentGenerator syntax creates ModelTransformerTest updates GraphQLTest creates entities creates migrations ...
2 parents 0aa308a + a3c6a49 commit 3c13d27

24 files changed

+736
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/composer.lock
22
/vendor
3+
*.orig

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language : php
2+
php : [5.6, 7.0, 7.1]
3+
cache : [directories : [$COMPOSER_CACHE_DIR, $HOME/.composer/cache, vendor]]
4+
install : composer update --no-interaction --prefer-dist
5+
script : vendor/bin/phpunit
6+
notifications :
7+
email : false
8+
9+
env :
10+
- TESTBENCH_VERSION=3.3.* LARAVEL_VERSION=5.3.*
11+
- TESTBENCH_VERSION=3.4.* LARAVEL_VERSION=5.4.*
12+
13+
before_install :
14+
- composer global require hirak/prestissimo --update-no-dev
15+
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update --prefer-dist
16+
- composer require "orchestra/testbench-browser-kit:${TESTBENCH_VERSION}" --no-update --prefer-dist

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ information about GraphQL in the [GraphQL Introduction](http://facebook.github.i
77
on the [React](http://facebook.github.io/react) blog or you can read the
88
[GraphQL specifications](https://facebook.github.io/graphql/).
99

10+
[![Latest Stable Version](https://poser.pugx.org/studio-net/laravel-graphql/v/stable)](https://packagist.org/packages/studio-net/laravel-graphql)
11+
[![Latest Unstable Version](https://poser.pugx.org/studio-net/laravel-graphql/v/unstable)](https://packagist.org/packages/studio-net/laravel-graphql)
12+
[![Total Downloads](https://poser.pugx.org/studio-net/laravel-graphql/downloads)](https://packagist.org/packages/studio-net/laravel-graphql)
13+
[![Monthly Downloads](https://poser.pugx.org/studio-net/laravel-graphql/d/monthly)](https://packagist.org/packages/studio-net/laravel-graphql)
14+
[![Daily Downloads](https://poser.pugx.org/studio-net/laravel-graphql/d/daily)](https://packagist.org/packages/studio-net/laravel-graphql)
15+
[![License](https://poser.pugx.org/studio-net/laravel-graphql/license)](https://packagist.org/packages/studio-net/laravel-graphql)
16+
[![Build Status](https://api.travis-ci.org/studio-net/laravel-graphql.svg?branch=master)](https://travis-ci.org/studio-net/laravel-graphql)
17+
1018
This is a work in progress.
1119
> Warning : this package is not abled to run in production yet
1220

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
}
1010
],
1111
"require": {
12-
"laravel/laravel": ">=5.0",
12+
"laravel/framework": ">=5.3",
1313
"webonyx/graphql-php": "^0.9.13",
1414
"doctrine/dbal": "^2.5"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^6.2",
18-
"orchestra/testbench": "^3.4"
17+
"phpunit/phpunit": "~4.0|~5.0",
18+
"orchestra/testbench-browser-kit": "3.3.*|3.4.*"
1919
},
2020
"autoload" : {
2121
"psr-4" : {

database/factories/Post.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
use Faker\Generator;
3+
use StudioNet\GraphQL\Tests\Entity;
4+
5+
$factory->define(Entity\Post::class, function(Generator $faker) {
6+
return [
7+
'title' => $faker->catchPhrase,
8+
'content' => $faker->text()
9+
];
10+
});
File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
/**
5+
* CreatePostsTable
6+
*
7+
* @see Migration
8+
*/
9+
class CreatePostsTable extends Migration {
10+
/**
11+
* Run the migrations.
12+
*
13+
* @return void
14+
*/
15+
public function up() {
16+
Schema::create('posts', function ($table) {
17+
$table->increments('id');
18+
$table->string('title');
19+
$table->text('content');
20+
$table->integer('user_id');
21+
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down() {
32+
Schema::drop('posts');
33+
}
34+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
/**
5+
* CreateUsersTable
6+
*
7+
* @see Migration
8+
*/
9+
class CreateUsersTable extends Migration {
10+
/**
11+
* Run the migrations.
12+
*
13+
* @return void
14+
*/
15+
public function up() {
16+
Schema::create('users', function ($table) {
17+
$table->increments('id');
18+
19+
$table->string('name');
20+
$table->string('email');
21+
$table->string('password');
22+
23+
$table->timestamps();
24+
});
25+
}
26+
27+
/**
28+
* Reverse the migrations.
29+
*
30+
* @return void
31+
*/
32+
public function down() {
33+
Schema::drop('users');
34+
}
35+
}

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<phpunit
33
backupGlobals="false"
44
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
56
colors="true"
67
convertErrorsToExceptions="true"
78
convertNoticesToExceptions="true"

src/Generator/EloquentGenerator.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,20 @@ public function getResolver(Model $model) {
3030
}
3131

3232
// Retrieve single node
33-
if (array_key_exists($primary, $args)) {
34-
return $builder->findOrFail($args[$primary]);
33+
if (array_key_exists('id', $args)) {
34+
return $builder->findOrFail($args['id']);
3535
}
3636

3737
foreach ($args as $key => $value) {
3838
switch ($key) {
39-
case 'after' : $builder->where($primary, '>', $value) ; break;
40-
case 'before' : $builder->where($primary, '<', $value) ; break;
41-
case 'skip' : $builder->skip($value) ; break;
42-
case 'take' : $builder->take($value) ; break;
39+
case 'after' : $builder = $builder->where($primary, '>', $value) ; break;
40+
case 'before' : $builder = $builder->where($primary, '<', $value) ; break;
41+
case 'skip' : $builder = $builder->skip($value) ; break;
42+
case 'take' : $builder = $builder->take($value) ; break;
4343
}
4444
}
4545

4646
return $builder->get();
4747
};
4848
}
49-
5049
}

0 commit comments

Comments
 (0)