2
votes

My project is built with vue.js and severless framework, when I try to integrate it with Aws AppSync and Amplify (by using amplify cli), it auto generated a schema.json under /src/graphql which is almost unreadable. So every time I want to change the schema i go to the appsync console, change it there, then I do one of the following:

  1. execute amplify api update in terminal so that it updates whatever has been change in the cloud and update my local schema accordingly.

  2. download the schema.json file from the appsync console after the change. going back and forth is very consuming.

So my question is:

  1. Can I somehow use schema.graphql in my project instead of the unreadable schema.json

  2. I also noticed if I comment out every line in schema.json or even removed the schema.json completely in /src/graphql, it does not give me any error when i run it, why is this happening?

Thanks in advance.

3

3 Answers

1
votes

This question is a little old, but it might help someone:

The schema.json file is the introspection schema [1]. It's designed to be machine-readable so your favourite library can help you validate your requests client-side, it's certainly not designed to be human-readable or editable.

Instead you should edit amplify/backend/api/<apiname>/schema.graphql. When you then amplify api push it will do the following:

  1. Process that schema file according to the directives and transformers at [2] (you can also add your own transformers if you want to add custom directives that manipulate the schema, cloudformation or other resources). The output of this process is in build/graphql.schema in your API folder.
  2. Builds cloudformation to deploy this, similar to what @peter-n does himself.
  3. Deploys it, and
  4. Fetches the introspection schema (schema.json) for you and saves it to the location given in schemaPath in .graphqlconfig.yml, which is your src/graphql directory by default.

[1] https://graphql.org/learn/introspection/

[2] https://docs.amplify.aws/cli/graphql-transformer/directives

0
votes

I don't have much experience with Amplify, but I have used AppSync with Serverless. I maintain the schema (using the cleaner SDL format) under version control in the repo, and a CI script uploads to S3, then update AppSync via Cloudformation (embedded in serverless.yml).

The AWS::AppSync::GraphQLSchema resource allows for an inline schema (not so clean) or a pull down from S3. Having a separate file also enables you to test locally and better track changes/drift.

0
votes
  1. Change the schema modal in amplify/backend/API/schema.graphql to change the schema, data sources, queries, etc. Refer following link to change schema modal

https://blog.grandstack.io/graphql-api-configuration-with-neo4j-graphql-js-bf7a1331c793