updateOrCreate not possible with apollo-client
See original GitHub issueGraphcool added an updateOrCreate method https://www.graph.cool/forum/t/input-type-mutations-in-graphcool/726/4. The $id
is not provided if its a new record. However, I’m not able to provide an optional $id
because I get an error ID
and ID!
are not compatible.
Intended outcome:
mutation UpdateItem(
$id: ID,
$name: String!,
){
updateOrCreateItem(
update: {
id: $id,
name: $name
}
create: {
name: $name
}
){
id
}
}
Actual outcome:
Save Options Error: GraphQL error: Variable '$id' expected value of type 'ID!' but value is undefined...
Version “apollo-client-preset”: “^1.0.5”, “apollo-codegen”: “^0.18.3”, “apollo-link-context”: “^1.0.3”, “react-apollo”: “^2.0.4”,
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Reading and writing data to the cache - Apollo GraphQL Docs
You can read and write data directly to the Apollo Client cache, without communicating with your GraphQL server. You can interact with data...
Read more >Create or Update 1:1 record on Dynamo DB related to Cognito ...
I've got troubles on trying either of two. userSub cannot be primary key. Is there any way to update (or create if not...
Read more >Vue GraphQL integration using Apollo Client - End Point Dev
With these you'll be able to: Manually run GraphQL queries and mutations from any Vue component via the this.$apollo helper; Automatically map ...
Read more >client-preset - GraphQL Code Generator
@apollo/client (since 3.2.0 , not when using React Components ... namingConvention : Available case functions in change-case-all are ...
Read more >Using GraphQL to perform queries - Jahia Academy
In addition, some graphQL fields may or may not be allowed for a user. ... Mutations are provided to update or create nodes....
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 FreeTop 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
Top GitHub Comments
That is right because apollo-client checks if a param that is marked as required is provided.
As mentioned in https://github.com/apollographql/apollo-client/issues/2861#issuecomment-357179901, this is not an
apollo-client
error. Thanks!