Ask Your Question
2

How can I divide my schema.graphql into several files within Amplify?

asked 2023-05-19 12:28:10 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-19 12:29:01 +0000

plato gravatar image

To divide your schema.graphql into several files within Amplify, follow these steps:

  1. Create a new folder in your Amplify project and name it "schema".

  2. Move your current schema.graphql file into that folder.

  3. Create a new file in the "schema" folder with a descriptive name, such as "User.graphql". This file will contain the schema for a User type.

  4. Copy the contents of the User type from the schema.graphql file into the User.graphql file.

  5. Repeat steps 3-4 for each type in your schema.

  6. In your schema.graphql file, remove the type definitions you have moved to separate files.

  7. Add the following line to the top of your schema.graphql file:

#import "./schema/User.graphql"

This tells GraphQL to import the User type definition from the User.graphql file.

  1. Repeat step 7 for each type definition file.

  2. Finally, run the following command to update your Amplify project:

amplify codegen

This will generate the necessary files for your new schema structure.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-19 12:28:10 +0000

Seen: 10 times

Last updated: May 19 '23