Skip to content

GraphQL Integration

Kenton Lam edited this page Sep 5, 2020 · 1 revision

The server defines the schema for GraphQL queries which can be used by the client.

For backend:

  • The schema.gql file should be automatically generated every time the server starts.
  • Ensure this file is committed and kept up to date when you change queries and entities.

For frontend:

  • Install the Apollo CLI tools with yarn global add apollo or similar.
  • Write GraphQL queries using the gql`some query here` syntax.
  • Run yarn apollo:codegen to generate Typescript types for your queries. The generated .ts are in src/graphql.
  • Modify your useQuery(...) to useQuery<T>(...) where T is the generated type.
Clone this wiki locally