adonis-gql
adonis-gql copied to clipboard
Scope of works
Provider basic
- [x] Provider base
- [x] Read schema
- [x] Read Resolver
- [x] Tests
- [x] Commands
Provider Advanced
- [x] Directive support
- [x] Accept middleware
- [ ] Subscription System
Resolvers and schemas will be structured following the structure that AdonisJS adopts in its controllers, respecting its particularities.
Defining the things
Inside start/graphql.js
you declare the schemas and resolvers.
You can call a callback in the schema to define the resolvers that are pertinent to it, so it's optional. In the same way you can define a resolver independent of a schema, but in this case you must pass the name and the controller of the same one.
const Gql = use('Gql')
Gql.schema('Post', () => {
Gql.query('Query/PostController')
Gql.mutation('Mutation/PostController')
})
Gql.schema('User')
Gql.mutation('User', 'Mutation/UserController')
Inside start/gqlKernel.js
you register the things described above.
Future will be the global middlewares and named middlewares.
const Gql = use('Gql')
Gql.register()
The controllers are in the app/Controllers/Gql
directory.
On the commands I think of following the style adopted by migrations, where we will have the term graphql
preceded by what we want.
Exemples
Make only the schema
Post:
adonis gql:schema Post
Make the schema
Post with the controllers for query
and mutation
:
adonis gql:schema Post -r
hello @HigoRibeiro , i think you must move this issue as an example and provide more examples and documentations at least an example of "Hello world"