Issues during extending the FastStore API schema
Development and deployment challenges may arise while extending FastStore API schema with GraphQL.
Keywords: FastStore | API extension | GraphQL | schema extensions | yarn generate | deploy preview
Although the FastStore API provides a GraphQL schema for ecommerce, you can extend it to access other or more specific information from your store. During this implementation, you may encounter issues such as local GraphQL changes not being reflected, schema differences between environments, or generation errors.
Solutions
GraphQL changes not visible or inconsistent across environments
If your GraphQL changes aren't visible during development, or if your deploy preview or production schema differs from the development one, the GraphQL layer likely needs optimization. This process ensures your latest code changes are reflected in the generated schema and types.
- Run
yarn generate(recommended) oryarn run faststore generate-graphqlin the project root.
You can run
yarn generatewhile the development server is running.
- If changes still aren't visible, or if differences between development and deploy preview/production persist, stop
yarn devand start it again.
GraphQL changes not visible in production or deploy preview
If changes are visible in development but not in the deploy preview or production, verify deployment inputs and build context.
- Confirm all API Extensions changes are committed to the deployed branch.
- Confirm the deploy preview/production build was triggered from the same branch and latest commit.
- Re-run
yarn generate(oryarn run faststore generate-graphql) locally and compare local behavior with the deployed result.
Type generation errors and warnings
If you see errors or warnings during generation, use the table below to identify the issue and the required action.
| Issue | Description | Solutions |
|---|---|---|
error Failed to run 'yarn generate:schema'. Please check your setup. | Schema generation failed, usually due to invalid schema extension files. | Review .graphql files in src/graphql/vtex/typeDefs and src/graphql/thirdParty/typeDefs for syntax and schema definition issues. |
error GraphQL was not optimized, and TS files were not updated. Changes in the GraphQL layer didn't take effect. | GraphQL optimization failed, usually due to invalid schema, resolvers, queries, or fragments. | Validate schema files, resolver files in src/graphql/(vtex or thirdParty)/resolvers, and query or fragment declarations in .ts and .tsx files. |
warn Failed to format generated files. 'yarn format:generated' threw errors. | Formatting step failed after generation. | This is a warning, not an error. Your GraphQL layer will still function correctly. If you want to investigate and resolve the formatting issue, follow these steps:
|
Error details
If the issue isn't clear from the messages above, run the generation command with debug output to identify exactly where the failure occurs.
- Run
yarn generate --debug. - Use the verbose output to identify the failing file or operation.