Environment information
- Amplify CLI: `@aws-amplify/backend-cli` (tested 1.8.0 and latest)
- Node: v22.12.0 (also reproducible on v20.19.4 in CI)
- OS: macOS (also fails in Amplify Console build environment)
- Framework: Next.js 15, Amplify Gen 2
Describe the bug
ampx generate graphql-client-code --format graphql-codegen fails with a SyntaxError: Unexpected <EOF> when the schema contains mutations or queries backed by @function resolvers.
Reproduction steps
- Create an Amplify Gen 2 project with a schema that includes
@function resolvers:
type Mutation {
myCustomMutation(input: MyInput!): MyResult
@function(name: "myLambdaFunction")
@aws_cognito_user_pools
}
-
Deploy the backend (so outputs exist)
-
Run:
npx ampx generate graphql-client-code --format graphql-codegen --branch dev --app-id <your-app-id>
Expected behavior
Codegen generates TypeScript types and operation documents for all schema types, skipping @function-backed operations gracefully (or generating stub operations for them).
Actual behavior
[SyntaxError] Syntax Error: Unexpected <EOF> (4:1)
2 |
3 |
> 4 |
| ^
The codegen appears to generate an empty .graphql operations file (because @function resolvers don't produce auto-generated client operations), and then the GraphQL parser attempts to parse the empty file and crashes on EOF.
Workaround
Using @graphql-codegen/cli (community package) with the typescript plugin reading schema.graphql directly generates schema types successfully. Frontend per-operation types (MutationVariables, QueryResult) are maintained manually.
Impact
Any Gen 2 project using @function resolvers cannot use the native ampx generate graphql-client-code command. This forces manual maintenance of frontend type files, which is error-prone and increases development overhead.
Additional context
- This has persisted across multiple CLI versions over the past year
- The project has 50+ mutations/queries, most backed by
@function resolvers
- The
@graphql-codegen/cli workaround works for Lambda types but cannot generate the per-operation types that ampx would normally produce
Environment information
Describe the bug
ampx generate graphql-client-code --format graphql-codegenfails with aSyntaxError: Unexpected <EOF>when the schema contains mutations or queries backed by@functionresolvers.Reproduction steps
@functionresolvers:Deploy the backend (so outputs exist)
Run:
Expected behavior
Codegen generates TypeScript types and operation documents for all schema types, skipping
@function-backed operations gracefully (or generating stub operations for them).Actual behavior
The codegen appears to generate an empty
.graphqloperations file (because@functionresolvers don't produce auto-generated client operations), and then the GraphQL parser attempts to parse the empty file and crashes on EOF.Workaround
Using
@graphql-codegen/cli(community package) with thetypescriptplugin readingschema.graphqldirectly generates schema types successfully. Frontend per-operation types (MutationVariables,QueryResult) are maintained manually.Impact
Any Gen 2 project using
@functionresolvers cannot use the nativeampx generate graphql-client-codecommand. This forces manual maintenance of frontend type files, which is error-prone and increases development overhead.Additional context
@functionresolvers@graphql-codegen/cliworkaround works for Lambda types but cannot generate the per-operation types thatampxwould normally produce