See more details at their repository on GitLab
1 - Installing Dependencies
$ npm install
2 - Run development server
$ npm run build
$ npm run start
🚀 Server ready at http://localhost:4000/graphql
🚀 Subscriptions ready at ws://localhost:4000/graphql
To create a schema, follow the steps below:
1 - Go to src/schema/index.js
and create the schema typeDef.
2 - Now it's time to create the Schema resolver. Create a resolver file in src/schema/resolvers
.
To create a schema, follow the steps below:
1 - Go to src/mutations
folder.
2 - Create a mutation file like below:
export default {
name: 'myMutation',
typeDef: `
input MyMutationInput {
email: String!
}
type MyMutationPayload {
user: User
}
`,
mutation: `
myMutation(input: MyMutationInput): MyMutationPayload
`,
resolver: async (_, args, { user }) => {
// Add mutation resolver here
},
};
We have a mock data that follows the real use case of the project. All mock resolvers are located on folder: src/mocks
To enable mocks, just set the environment variable: MOCKS=true
- me: User
- DoLogin
We can make queires and mutations as a user. See the mock user data below:
Email: bruce.wayne@gmail.com
Password: batpassword
Token: iambatman
{
"Authorization": "Bearer iambatman"
}
Tip: use the JSON above to test as user in GraphQL Playground.