Skip to content

GraphQLScalarType.parse_literal is called with two arguments instead of one when Query variables are present. #93

Closed
@rafalp

Description

@rafalp

It has been reported to us that when custom scalar with parse_literal is given literal value in query that has been called with variables, function passed to parse_literal will be called with two arguments instead of one: ast of literal and dict with query variables:

query TestQuery($variable: ID) {
  field(scalar: "STRING")
  otherField(id: $variable)
}

This produces tricky to debug error, eg.:

Argument 'scalar' has invalid value "STRING"

However actual error is TypeError for function being called with two arguments instead of one.

However GraphQL.js documentation doesn't mention this behaviour:
https://graphql.org/graphql-js/type/#graphqlscalartype

I've found that value_from_ast_untyped is called with two arguments in situation when query variables are present, but couldn't find anything about custom parse_literal.

Is this intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions