amplify/backend/api/myproject/schema.graphql - single source of truth?
** Which Category is your question related to? ** AppSync
** What AWS Services are you utilizing? ** AppSync
** Provide additional details e.g. code snippets ** In amplify/backend/api/myproject/schema.graphql, I define such a type with GraphQL transformer:
type Item @model {
id: ID!
createdAt: AWSDateTime
content: String!
}
In this way, I am able to access createdAt attribute of the item, as it will be filled by server end as suggested in https://github.com/aws-amplify/amplify-cli/issues/401.
However, I want to remove createdAt from CreateItemInput and UpdateItemInput, that are auto-generated according to codegen - flow 2.
input CreateItemInput {
id: ID
createdAt: AWSDateTime
content: String
}
input UpdateItemInput {
id: ID!
createdAt: AWSDateTime
content: String
}
My questions:
- Can I do it on appsync console Schema and somehow "pull" it?
- Can I do it with myproject/build/schema.graphql and somehow "push" it?
- Or myproject/schema.graphql is the single source of truth and there is no way to manually tune the transformed schema AND generated resolvers?
For question 3, currently, there is no way to sync generated resolver code (e.g., amplify/backend/api/myproject/build/resolvers/Mutation.createItem.request) with resolver in AppSync console. Edit resolver on AppSync console directly. #30 If you really want to pull change from AppSync console, read this twitter thread
@YikSanChan
-
Currently, there's not a clean way to pull your changes from the console, but yes you can follow the methodology mentioned in the twitter thread mentioned above in which case you would no longer be able to manage your API through the CLI (using the annotated schema) and you would have to rely on the console to make all your changes.
-
I'll let @mikeparisstuff answer that, but i beleive you can do so
-
You can use the
amplify push —no-gql-overridecommand to manually modify your generated resolvers and then push it. Note: this command basically would not automatically compile the annotated graphql schema and override the resolvers.
@kaustavghosh06 From https://github.com/aws-amplify/amplify-cli
The 'no-gql-override' flag does not automatically compile your annotated GraphQL schema and will override your local AppSync resolvers and templates.
But I don't fully understand what it does based on the documentation. "...will override your local AppSync resolvers and templates", what is local AppSync resolvers? Does it mean: we can modify resolver files locally (under /amplify/backend?) and push the change to AppSync console?
But isn't that meaning that everytime you update the api, you can't let the cli do the transform for you (since it will modify your previous choices), or let the cli do the transform and edit back the previous changes?
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.