Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 1.67 KB

develop.md

File metadata and controls

22 lines (19 loc) · 1.67 KB

How to support a new operation

Basics about GraphQL

  • 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.

To add a new operation

  • 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 {...} or type 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.
    • response type defines response after new operation is executed.
  • Run go run github.com/99designs/gqlgen generate in catalog-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.

References