Skip to content

Scalars.GraphQLID#serialize should support serialization of Long  #313

Closed

Description

@mindas

My underlying object which I am exposing via graphql-java has identifier of type Long.
The object is loaded correctly but when the results are returned, id is omitted.
This happens because of the following lines in Scalars.java:171-178

if (input instanceof String) {
   return input;
}
if (input instanceof Integer) {
   return String.valueOf(input);
}

return null;

Would it not make sense to add handling for Long type here? Thank you!

Activity

  1. bbakerman commented on Feb 1, 2017

    @bbakerman
    Member

    I agree - I think it might be better as something like

            if (input != null) {
                return String.valueof(input);
            }
            return null;
    

    The toString() of an object is a valid identifier in the absence of any other "interface" to say otherwise

  2. bbakerman commented on Feb 1, 2017

    @bbakerman
    Member

    The spec is ambiguous about this

    http://facebook.github.io/graphql/#sec-ID

    As in its the graphql "server" implementations choice. However it does say that errors should be raised if an input is not acceptable rather than null being generated.

    I think graphql-java should be more lenient on ID types in this case

  3. added this to the milestone on May 20, 2017
  4. andimarek commented on Jun 5, 2017

    @andimarek
    Member

    That we produce an Error instead of null is fixed with #455 (and further modified with #487 )

  5. bbakerman commented on Jun 18, 2017

    @bbakerman
    Member

    A PR for this has been merged

  6. bbakerman commented on Jun 18, 2017

    @bbakerman
    Member
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions