I'm building a React + aws AppSync graphql web app with amplify. Have been enjoying this fantastic tool, but couldn't get the codegen
to work as I expected - it doesn't generate base types for TypeScript frontend.
Say I feed this schema.graphql
file to amplify codegen
:
type Event @model {
id: ID!
name: String
effects: [EventEffects]
}
type EventEffect {
name: String
delta: Int
}
with this 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
Then codegen gives me API.ts
and queries.ts
, mutations.ts
, subscriptions.ts
and schema.json
. The problem is, there's no base types generated.
I can get interface for Event with:
export interface Event
extends Omit<Exclude<GetEventQuery["getEvent"], null>, "__typename"> {}
But there's no way to get interface for EventEffect
, since I didn't add @modal
directive.
To narrow down my questions:
Is it by design that amplify doesn't generate base types?
How to get base type for
EventEffect
?What is the
schema.json
generated used for?