Skip to content

Sharing schema

Tom Andrews edited this page Sep 5, 2018 · 2 revisions

Sharing schema

Base problem

Currently we share the graphql schema between the UI and API. This is because the UI needs to know the schema for linting and at runtime apollo client needs to know the fragment types so it can map the data correctly.

Current solution

We share the schema in a separate repository and then publish this to npm and include it both API and UI. The changes to the API and Schema need to be coordinated and the npm credentials to publish need to be shared between the team.

Proposed solution

  1. Move the schema into the API so they are held together.
  2. Use a build/dev time task to perform an introspection query to extract the schema from the API the environment is pointing at for linting.
  3. At runtime perform a query to extract the fragment types from the API the UI is running against.

Issues with proposed solution

  1. Currently we lint as a part of the build process (as well as the separate lint task) this means that it needs to know the full schema for the linting. We build the app in a number of places (travis, netlify and concourse) so we need to stop the building from performing linting and just run that in travis (and dev) so there is no extra dependency on a running API.
  2. This creates a dependency on basic dev commands in author and having a running API.
Clone this wiki locally