Skip to content

persist/push: Avoid sending object properties not declared in input types #120

@johnrix

Description

@johnrix

Currently 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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions