Skip to content

Commit c47b78f

Browse files
committed
Small improvement to README
1 parent 4c27e1d commit c47b78f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,39 @@ public function users(int $limit, int $offset)
126126

127127
Note: for container discovery to work, you must pass the container when constructing the `ControllerQueryProvider` object.
128128

129+
Usage
130+
-----
131+
132+
```bash
133+
$ composer require thecodingmachine/graphql-controllers
134+
```
135+
136+
The package contains a http-interop compatible middleware: `TheCodingMachine\GraphQL\Controllers\GraphQLMiddleware`.
137+
Put this middleware in your middleware pipe.
138+
139+
The middleware expects a GraphQL schema to be created. This package comes with a GraphQL schema compatible with Youshido
140+
schemas that will automatically be filled from the GraphQL controllers you will write.
141+
142+
Controllers will be fetched from the container (it must be PSR-11 compliant).
143+
144+
Pseudo-code to initialize the middleware looks like this:
145+
146+
```php
147+
$queryProvider = new AggregateControllerQueryProvider([
148+
"myController1", // These are the name of entries in the container to fetch the GraphQL controllers
149+
"myController2"
150+
],
151+
$container, // The container containing the controllers (PSR-11 compliant),
152+
$annotationReader, // A Doctrine annotation reader
153+
$typeMapper, // Object used to map PHP classes to GraphQL types.
154+
$hydrator, // Object used to create Objects from sent data (mostly for mutation)
155+
$authenticationService, // Object to manage authentication (the @Logged annotation)
156+
AuthorizationServiceInterface $authorizationService // Object to manage authorization (the @Right annotation)
157+
)
158+
);
159+
```
160+
161+
129162

130163
Troubleshooting
131164
---------------

0 commit comments

Comments
 (0)