Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.