Skip to content

Scalar types' methods should respect graphql-core's API #1419

@fugal-dy

Description

@fugal-dy

When making a query with multiple arguments with variables and literals, the query will fails as soon as it comes to a literal, if it's a type that implements parse_literal that does not accept an additional _variables parameter.

Steps to reproduce

Define a schema with an attribute taking two arguments.

Execute a query with the two arguments only one of which is set by a variable value the other by a literal value.

query =  """
  query Test($a: GenericScalar){{
    generic(inputA: $a, inputB: "foo")
  }}
"""

The query fails with an error GraphQLError("Argument 'inputB' has invalid value 'foo'."event though 'foo' is a valid value for inputB.

What is the expected behavior

Since it's a valid query it's supposed to not return an error.

Solution
python-graphql/graphql-core proposes a strict API for Scalar-types all of which implement the parse_literal method accepting a second parameter for _variables

graphene's Scalar-types should respect the API if it inherits from graphql-core type classes and accept kwarg _variables=None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions