Skip to content
This repository was archived by the owner on Mar 29, 2020. It is now read-only.

Commit dd42543

Browse files
committed
Merge pull request #10 from nuwave/develop
Merge develop branch
2 parents 03b6c7b + aa32636 commit dd42543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4057
-695
lines changed

README.md

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,63 @@
1-
# laravel-graphql-relay
1+
# laravel-grapql-relay #
22

3-
## Documentation currently under development
3+
Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package extends graphql-php to work with Laravel and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).
44

5-
Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package is used alongside [laravel-graphql](https://github.com/Folkloreatelier/laravel-graphql) and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).
5+
Although this package no longer depends on [laraval-graphql](https://github.com/Folkloreatelier/laravel-graphql), it laid the foundation for this package which likely wouldn't exist without it. It is also a great alternative if you are using GraphQL w/o support for Relay.
66

7-
## Installation
7+
Because this package is still in the early stages, breaking changes will occur. We will keep the documentation updated with the current release. Please feel free to contribute, PR are absolutely welcome!
8+
9+
### Installation ###
810

911
You must then modify your composer.json file and run composer update to include the latest version of the package in your project.
1012

11-
```json
13+
```php
1214
"require": {
13-
"nuwave/laravel-graphql-relay": "0.2.*"
15+
"nuwave/laravel-graphql-relay": "0.3.*"
1416
}
1517
```
1618

17-
Or you can use the ```composer require``` command from your terminal.
19+
Or you can use the composer require command from your terminal.
1820

19-
```json
21+
```
2022
composer require nuwave/laravel-graphql-relay
2123
```
2224

2325
Add the service provider to your ```app/config.php``` file
2426

25-
```php
26-
Nuwave\Relay\ServiceProvider::class
27+
```
28+
Nuwave\Relay\LaravelServiceProvider::class
2729
```
2830

29-
Add the Relay facade to your ```app/config.php``` file
31+
Add the Relay & GraphQL facade to your app/config.php file
3032

31-
```php
33+
```
34+
'GraphQL' => Nuwave\Relay\Facades\GraphQL::class,
3235
'Relay' => Nuwave\Relay\Facades\Relay::class,
3336
```
3437

3538
Publish the configuration file
3639

37-
```php
38-
php artisan vendor:publish --provider="Nuwave\Relay\ServiceProvider"
40+
```
41+
php artisan vendor:publish --provider="Nuwave\Relay\LaravelServiceProvider"
3942
```
4043

41-
Add your Mutations, Queries and Types to the ```config/relay.php``` file
44+
Create a ```schema.php``` file and add the path to the config
4245

43-
```php
44-
// Example:
45-
46-
return [
47-
'schema' => function () {
48-
// Added by default
49-
Relay::group(['namespace' => 'Nuwave\\Relay'], function () {
50-
Relay::group(['namespace' => 'Node'], function () {
51-
Relay::query('node', 'NodeQuery');
52-
Relay::type('node', 'NodeType');
53-
});
54-
55-
Relay::type('pageInfo', 'Types\\PageInfoType');
56-
});
57-
58-
// Your mutations, queries and types
59-
Relay::group(['namespace' => 'App\\Http\\GraphQL'], function () {
60-
Relay::group(['namespace' => 'Mutations'], function () {
61-
Relay::mutation('createUser', 'CreateUserMutation');
62-
});
63-
64-
Relay::group(['namespace' => 'Queries', function () {
65-
Relay::query('userQuery', 'UserQuery');
66-
});
67-
68-
Relay::group(['namespace' => 'Types'], function () {
69-
Relay::type('user', 'UserType');
70-
Relay::type('event', 'EventType');
71-
});
72-
});
73-
}
74-
];
46+
```
47+
// config/relay.php
48+
// ...
49+
'schema' => [
50+
'path' => 'Http/schema.php',
51+
'output' => null,
52+
],
7553
```
7654

77-
To generate a ```schema.json``` file (used with the [Babel Relay Plugin](https://facebook.github.io/relay/docs/guides-babel-plugin.html#content))
55+
To generate a ```schema.json``` file (used with the Babel Relay Plugin):
7856

79-
```php
57+
```
8058
php artisan relay:schema
8159
```
8260

83-
For additional documentation, please read the [Wiki](https://github.com/nuwave/laravel-graphql-relay/wiki/1.-GraphQL-and-Relay)
61+
*You can customize the output path in the ```relay.php``` config file under ```schema.output```*
62+
63+
For additional documentation, look through the docs folder or read the Wiki.

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
}
2626
},
2727
"require": {
28-
"folklore/graphql": "0.*",
29-
"illuminate/console": "5.*"
28+
"webonyx/graphql-php": "~0.5",
29+
"illuminate/console": "5.*",
30+
"doctrine/dbal": "^2.5"
3031
}
3132
}

config/config.php

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
11
<?php
2-
/*
3-
|--------------------------------------------------------------------------
4-
| Schema File
5-
|--------------------------------------------------------------------------
6-
|
7-
| You can utilize this file to register all of you GraphQL schma queries
8-
| and mutations. You can group collections together by namespace or middlware.
9-
|
10-
*/
112

123
return [
13-
'schema' => function () {
14-
Relay::group(['namespace' => 'Nuwave\\Relay'], function () {
15-
Relay::group(['namespace' => 'Node'], function () {
16-
Relay::query('node', 'NodeQuery');
17-
Relay::type('node', 'NodeType');
18-
});
194

20-
Relay::type('pageInfo', 'Types\\PageInfoType');
21-
});
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Namespace registry
8+
|--------------------------------------------------------------------------
9+
|
10+
| This package provides a set of commands to make it easy for you to
11+
| create new parts in your GraphQL schema. Change these values to
12+
| match the namespaces you'd like each piece to be created in.
13+
|
14+
*/
2215

23-
// Additional Queries, Mutations and Types...
24-
}
16+
'namespaces' => [
17+
'mutations' => 'App\\GraphQL\\Mutations',
18+
'queries' => 'App\\GraphQL\\Queries',
19+
'types' => 'App\\GraphQL\\Types',
20+
'fields' => 'App\\GraphQL\\Fields',
21+
],
22+
23+
/*
24+
|--------------------------------------------------------------------------
25+
| Schema declaration
26+
|--------------------------------------------------------------------------
27+
|
28+
| This is a path that points to where your Relay schema is located
29+
| relative to the app path. You should define your entire Relay
30+
| schema in this file. Declare any Relay queries, mutations,
31+
| and types here instead of laravel-graphql config file.
32+
|
33+
*/
34+
35+
'schema' => [
36+
'path' => null,
37+
'output' => null,
38+
],
39+
40+
'controller' => 'Nuwave\Relay\Http\Controllers\LaravelController@query',
41+
'model_path' => 'App\\Models',
42+
'camel_case' => false,
2543
];

docs/Configuration.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Configuration ##
2+
3+
When publishing the configuration, the package will create a ```relay.php``` file in your ```config``` folder.
4+
5+
### Namespaces ###
6+
7+
```php
8+
'namespaces' => [
9+
'mutations' => 'App\\GraphQL\\Mutations',
10+
'queries' => 'App\\GraphQL\\Queries',
11+
'types' => 'App\\GraphQL\\Types',
12+
'fields' => 'App\\GraphQL\\Fields',
13+
],
14+
```
15+
16+
This package provides a list of commands that allows you to create Types, Mutations, Queries and Fields. You can specify the namespaces you would like the package to use when generating the files.
17+
18+
### Schema ###
19+
20+
```php
21+
'schema' => [
22+
'file' => 'Http/GraphQL/schema.php',
23+
'output' => null,
24+
]
25+
```
26+
27+
** File **
28+
29+
Set the location of your schema file. (A schema is similar to your routes.php file and defines your Types, Mutations and Queries for GraphQL. Read More)
30+
31+
** Output **
32+
33+
This is the location where your generated ```schema.json``` will be created/updated. (This json file is used by the [Babel Relay Plugin](https://facebook.github.io/relay/docs/guides-babel-plugin.html#content)).
34+
35+
### Eloquent ###
36+
37+
```php
38+
'eloquent' => [
39+
'path' => 'App\\Models',
40+
'camel_case' => false
41+
]
42+
```
43+
44+
** Path **
45+
46+
The package allows you to create Types based off of your Eloquent models. You can use the ```path``` to define the namespace of your models or you can use the full namespace when generating Types from the console (Read More).
47+
48+
** Camel Case **
49+
50+
Camel casing is quite common in javascript, but Laravel's database column naming convention is snake case. If you would like your Eloquent model's generated fields converted to camel case, you may set this to true.
51+
52+
*This works great with the [Eloquence package](https://github.com/kirkbushell/eloquence).*

docs/Overview.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# laravel-grapql-relay #
2+
3+
Use Facebook [GraphQL](http://facebook.github.io/graphql/) with [React Relay](https://facebook.github.io/relay/). This package extends graphql-php to work with Laravel and is currently **a work in progress**. You can reference what specifications GraphQL needs to provide to work with Relay in the [documentation](https://facebook.github.io/relay/docs/graphql-relay-specification.html#content).
4+
5+
Although this package no longer depends on [laraval-graphql](https://github.com/Folkloreatelier/laravel-graphql), it laid the foundation for this package which likely wouldn't exist without it. It is also a great alternative if you are using GraphQL w/o support for Relay.
6+
7+
Because this package is still in the early stages, breaking changes will occur. We will keep the documentation updated with the current release. Please feel free to contribute, PR are absolutely welcome!
8+
9+
### Installation ###
10+
11+
You must then modify your composer.json file and run composer update to include the latest version of the package in your project.
12+
13+
```php
14+
"require": {
15+
"nuwave/laravel-graphql-relay": "0.3.*"
16+
}
17+
```
18+
19+
Or you can use the composer require command from your terminal.
20+
21+
```
22+
composer require nuwave/laravel-graphql-relay
23+
```
24+
25+
Add the service provider to your ```app/config.php``` file
26+
27+
```
28+
Nuwave\Relay\LaravelServiceProvider::class
29+
```
30+
31+
Add the Relay & GraphQL facade to your app/config.php file
32+
33+
```
34+
'GraphQL' => Nuwave\Relay\Facades\GraphQL::class,
35+
'Relay' => Nuwave\Relay\Facades\Relay::class,
36+
```
37+
38+
Publish the configuration file
39+
40+
```
41+
php artisan vendor:publish --provider="Nuwave\Relay\LaravelServiceProvider"
42+
```
43+
44+
Create a ```schema.php``` file and add the path to the config
45+
46+
```
47+
// config/relay.php
48+
// ...
49+
'schema' => [
50+
'path' => 'Http/schema.php',
51+
'output' => null,
52+
],
53+
```
54+
55+
To generate a ```schema.json``` file (used with the Babel Relay Plugin):
56+
57+
```
58+
php artisan relay:schema
59+
```
60+
61+
*You can customize the output path in the ```relay.php``` config file under ```schema.output```*
62+
63+
For additional documentation, look through the docs folder or read the Wiki.

0 commit comments

Comments
 (0)