Override generated query
See original GitHub issueWhich Category is your question related to?
Graphql
Amplify CLI Version
6.0.0
What AWS Services are you utilizing?
Auth, Functions, Graphql, Storage
Provide additional details e.g. code snippets
I have a schema like this:
type Foo @model {
id: ID!
.... other attributes
}
I understand that on amplify push, I automatically get the type Query, with getFoo(id: ID)
. All well.
After a while, I wish to override this query - I want to use the @function
directive to call a lambda function for this query only. How do I go about with it? When I tried to define it as:
type Query {
getFoo(id: ID!): Foo @function(name: "blah")
}
I got the following error on amplify push
:
Object type extension 'Query' cannot redeclare field getFoo
An error occurred during the push operation: Object type extension 'Query' cannot redeclare field getFoo
From what I see, I should rename the getFoo query to something else and then attach the function to it. I can no longer use getFoo
itself… Is that right or there is a way to override?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
API (GraphQL) - Overwrite & customize resolvers - Amplify Docs
Learn how to overwrite or add custom resolvers with Amplify. ... Create resolvers for newly created Query , Mutation or Subscription by creating...
Read more >How do I overwrite SQL generated by a View? - InterWorks
There are several reasons to overwrite an SQL query generated by a view whether it's to improve performance or join to tables not...
Read more >SQL Query Override - Informatica Documentation
SQL Query Override ... You can alter or override the default query in the mapping by entering SQL override in the Properties settings...
Read more >Can I override Entity Framework query generator?
You don't need to override anything. Your best bet would be to just execute a plain SQL query through Entity Framework and have...
Read more >Override default queries | Vue Storefront 2 for Magento
To override one or multiple queries without creating a custom composable for each usage, you can override the defaults ones with the customQueries...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@yuth Thank you. Your approach worked. To summarize, in order to override the auto generated query, I had to first remove the existing auto generated one with:
Then I ran
amplify push
. After this ran successfully, I then introduced my overridden query:and ran
amplify push
again. This auto generated thelistFoo
query as well as allowed me to override thegetFoo
query.My question has been answered. This issue can now be closed. Thank you for your timely assistance.
@PatrykMilewski you are right. When you override a query, mutation or a subscription, you will have to specify the field names of all the operations that you are not overriding. So in this case the schema will look like if you want the list query to be generated.