Skip to content

Introspection on default value for input object is not following GraphQL spec #296

Closed

Description

@nex-ray

I defined an input object with a HashMap as default value. Introspection on the default value gives the toString() value of the HashMap (see graphql.introspection#__InputValue). However, GraphQL specification requires the string to be encoded using GraphQL language.

As a result, GraphiQL would fail because of the incorrect introspection result.

Activity

  1. added a commit that references this issue on Jan 12, 2017
  2. dminkovsky commented on Jan 12, 2017

    @dminkovsky
    Contributor
  3. dminkovsky commented on Jan 13, 2017

    @dminkovsky
    Contributor
  4. bbakerman commented on Apr 21, 2017

    @bbakerman
    Member

    I looked into this further. It does today do the wrong thing but the expected result linked here is not correct I don't think

    The spec says is should be a field called "defautValue" and a graphql language encoded "String representation".

    Looking at the reference implementation they do this

    https://github.com/graphql/graphql-js/blob/master/src/type/introspection.js

     resolve: inputVal => isInvalid(inputVal.defaultValue) ?
        null :
        print(astFromValue(inputVal.defaultValue, inputVal.type))
    

    This takes the input default value object and the logical graphql type and reverse runs it back though AST and then an AST printer.

    We dont yet have an AST printer

    There is a PR : #386 that provides a runtime type printer. But not a printer of AST values

    The AST vales in graphql-java are represented by classes such as graphql.language.IntValue and graphql.language.StringValue etc..

    In order to fix this to spec we would have to write a AST printer and then reimplement the astFromValue method mentioned above.

    I will see if I can get this done

  5. added 3 commits that reference this issue on Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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