Currently, I am in the process of creating a web application using React, AWS AppSync GraphQL, and Amplify. While I have found this to be an incredible tool, I have encountered an issue with the codegen
not generating base types as expected for the TypeScript frontend.
Let's take a look at the schema.graphql
file that I supplied to amplify codegen
:
type Event @model {
id: ID!
name: String
effects: [EventEffects]
}
type EventEffect {
name: String
delta: Int
}
Along with this configuration in the config.yml
:
projects:
myapi:
schemaPath: amplify/backend/api/myapi/build/schema.graphql
includes:
- src/graphql/**/*.ts
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: typescript
generatedFileName: src/API.ts
docsFilePath: src/graphql
extensions:
amplify:
version: 3
When running the codegen command, it produces files such as API.ts
, queries.ts
, mutations.ts
, subscriptions.ts
, and schema.json
. However, I noticed that no base types are being generated.
I was able to obtain an interface for Event
using:
export interface Event
extends Omit<Exclude<GetEventQuery["getEvent"], null>, "__typename"> {}
Unfortunately, there doesn't seem to be a way to get an interface for EventEffect
since I forgot to add the @modal
directive.
To sum up my inquiries:
Is it intentional that Amplify does not generate base types?
How can I acquire a base type for
EventEffect
?What purpose does the generated
schema.json
serve?