GithubHelp home page GithubHelp logo

Comments (6)

will-weiss avatar will-weiss commented on April 18, 2024

Perhaps you could accomplish this using

UpdateToDoMutation = new GraphQLObjectType
  type: ToDo
  args:
    id:    type: new GraphQLNonNull GraphQLID
    set: type: ToDoInput
    unset: type: new GraphQLList(GraphQLString)
  resolve: (root, args)->   # ...

then you could write:

mutation M {
  updateToDo(id: 3, set: {whatToDo: 'whatever'}, unset: ['assignee'] { ... }
}

achieving the desired goal within the bounds of the language specification.

from graphql-js.

leebyron avatar leebyron commented on April 18, 2024

The primary issue here is that most environments do not distinguish between null and undefined in the way JavaScript does. Since GraphQL is designed to be a thin layer atop many different environments, we can't always support the distinction.

I think @will-weiss's suggestion is closer to what you want. To explicitly declare the things you are removing in a mutation.

from graphql-js.

leebyron avatar leebyron commented on April 18, 2024

One change that I can make that should make working with APIs that treat null specially is to also omit the not set object properties on the internal value.

from graphql-js.

guigrpa avatar guigrpa commented on April 18, 2024

Yes, the workaround is really nice. I got it going without problems, thanks a lot for the idea. Regarding the reason behind the spec, I understand better now - but it's a pity I can't use a cleaner API considering that I have JS on both client and server.

On Tue, Aug 11, 2015 at 10:23 PM, Lee Byron [email protected]
wrote:

One change that I can make that should make working with APIs that treat null specially is to also omit the not set object properties on the internal value.

Reply to this email directly or view it on GitHub:
#112 (comment)

from graphql-js.

leebyron avatar leebyron commented on April 18, 2024

2734d01 and 44c9daf implement the change that omits properties from arguments and input objects that were not provided, rather than their previous behavior of being set to null.

Hopefully this change will help when being paired with APIs which treat null differently from undefined.

from graphql-js.

leebyron avatar leebyron commented on April 18, 2024

These changes will go out in the next version release.

from graphql-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.