Skip to content

Commit

Permalink
* tweak readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Apr 27, 2016
1 parent d0bf1de commit 82e915f
Showing 1 changed file with 2 additions and 74 deletions.
76 changes: 2 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,81 +92,9 @@ activate routes in your global `Routes.yaml` file:
variables:
'endpoint': 'test'

Congratulations, your first GraphQL API is done and you should be able to invoke the GraphiQL IDE by browsing to `/test`:
**Congratulations**, your first GraphQL API is done and you should be able to invoke the GraphiQL IDE by browsing to `/test`:

![](graphiql.png)


## More advanced tutorial

Again, start with the Root Query definition

`ExampleRootQuery.php`:

<?php
namespace Your\Package;

use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use Wwwision\GraphQL\TypeResolver;

class ExampleRootQuery extends ObjectType
{
/**
* @param TypeResolver $typeResolver
*/
public function __construct(TypeResolver $typeResolver)
{
return parent::__construct([
'name' => 'ExampleRootQuery',
'fields' => [
'ping' => [
'type' => Type::string(),
'resolve' => function () {
return 'pong';
},
],
],
]);
}
}

Now register this endpoint like so:

`Settings.yaml`:

Wwwision:
GraphQL:
endpoints:
'test':
'querySchema': 'Your\Package\ExampleRootQuery'

And, lastly, activate the corresponding routes:

`Settings.yaml`:

TYPO3:
Flow:
mvc:
routes:
'Wwwision.GraphQL':
variables:
'endpoint': 'test'

This will make the endpoint "test" available under `/test`.

Note: If you already have more specific routes in place, or want to provide multiple GraphQL endpoints you can as well
activate routes in your global `Routes.yaml` file:

-
name: 'GraphQL API'
uriPattern: '<GraphQLSubroutes>'
subRoutes:
'GraphQLSubroutes':
package: 'Wwwision.GraphQL'
variables:
'endpoint': 'test'

Congratulations, your first GraphQL API is done and you should be able to invoke the GraphiQL IDE by browsing to `/test`:

![](graphiql_01.png)
For a more advanced example, have a look at the [Neos Content Repository implementation](https://github.com/bwaidelich/Wwwision.Neos.GraphQL)

0 comments on commit 82e915f

Please sign in to comment.