persist/push: Avoid sending object properties not declared in input types
See original GitHub issueCurrently when pushing an object back to my GraphQL API, I can control the name of the input type for the update request handily using the adapter method getInputTypeName
.
However, despite returning the name of an input type that is defined in my schema, the plugin encodes all values of my object into the push request rather than just those defined in the input type.
Using the example from the documentation, if my updatePost
mutation only allowed changes to the content and title, but not the user, my schema might look something like this:
type Post {
id: ID!
userId: ID!
title: String
content: String
....
}
input PostInput {
title: String
content: String
}
type Mutation {
updatePost(id: Int!, post: PostInput!): Post
}
However, if I tried to $push()
an existing post, I will get an error from the GraphQL server, since all of the Post properties are getting encoded in the Input object, despite the input type only having title and content fields.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
Good News:
This is an issue in my current project too. The best reason to tackle that 😉
I’ll provide a patch this week.
This should be fixed in version 1.0.0-rc.39.