- Please go through the basics in GraphQL first. Tutorials in references may be helpful to get you familiar with GraphQL.
- Important terms in GraphQL:
- Query: user-defined read operations.
- Mutation: user-defined write operations.
- Edit schema.graphqls to add a new operation you want. Depending on whether is a query or mutation, you need to add the new operation into
type Query {...}
ortype Mutation {...}
.- Formula for this new operation is
Operation-name(input parameters) [response type]
. Operation-name
is the name of the newly added operation.input parameters
are list of input parameters for the new operation. The exclamation mark!
after the input paramter implies that it is required and not optional.- For write operations (muation), we require input parameters contain a
token
parameter. A valid token with correct access is requred to perform such operation.
- For write operations (muation), we require input parameters contain a
response type
defines response after new operation is executed.
- Formula for this new operation is
- Run
go run github.com/99designs/gqlgen generate
incatalog-server
directory to generate codes which are required to support the newly added operation. - schema.resolvers.go file now contains a new resolver function with the same name as the newly added operation. You only need to implement the new empty resolver function to support the new operation.