Git Product home page Git Product logo

Comments (2)

rmosolgo avatar rmosolgo commented on August 28, 2024 3

Hey, thanks for asking. It was probably mistakenly added a long time ago 🙈 . I bet nobody has reported the problem since it can be worked around by removing the !.

Thanks for linking the relevant spec, @benjie -- I agree, removing it sounds like the right way forward.

from graphql-ruby.

benjie avatar benjie commented on August 28, 2024 2

I can confirm that my understanding of the spec suggests this:

query MyQuery($skip: Boolean! = true) {
  __typename @skip(if: $skip)
}

is a valid query for any GraphQL schema, even with no variables provided.

CoerceVariableValues in the spec details what happens when there's a default value but no supplied value:

3.g. If hasValue is not true and defaultValue exists (including null):
3.g.i. Add an entry to coercedValues named variableName with the value defaultValue.

As far as I am aware, there is no rule in the spec forbidding a defaultValue on a non-null variable, nor on arguments nor on input fields. These positions are "required" if they are a non-nullable type and they have no default. Giving them a default makes them "optional" (they're also optional if they are nullable).

Note to self on `= null` default

Note to self: having = null is not permitted due to the Values of Correct Type rule; namely:

Literal values must be compatible with the type expected in the position they are found as per the coercion rules defined in the Type System chapter.

See https://github.com/graphql/graphql-spec/pull/793/files#diff-0f02d73330245629f776bb875e5ca2b30978a716732abca136afdd028d5cd33c for related PR that I really should get back around to.

from graphql-ruby.

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.