Skip to content

Support for null Enum values in 0.9.5 does not work for arguments #840

Closed
@exogen

Description

@exogen

A GraphBrainz test started failing with graphql-js v0.9.5 and above. I have an enum like:

export const CoverArtImageSize = new GraphQLEnumType({
  name: 'CoverArtImageSize',
  description: `The image sizes that may be requested at the [Cover Art
Archive](https://musicbrainz.org/doc/Cover_Art_Archive).`,
  values: {
    SMALL: {
      name: 'Small',
      description: 'A maximum dimension of 250px.',
      value: 250
    },
    LARGE: {
      name: 'Large',
      description: 'A maximum dimension of 500px.',
      value: 500
    },
    FULL: {
      name: 'Full',
      description: 'The image’s original dimensions, with no maximum.',
      value: null
    }
  }
})

Note that FULL has the value null. (Yes, I had this null valued Enum even before it was 'officially' supported, and simply worked around it by checking for 'FULL' in the resolver.)

As of v0.9.5, I'm no longer able to supply FULL as an argument, as in this query:

  {
    lookup {
      release(mbid: "b84ee12a-09ef-421b-82de-0441a926375b") {
        coverArt {
          front(size: LARGE)
          back(size: SMALL)
          fullFront: front(size: FULL)
        }
      }
    }
  }

This now results in an error from the server:

GraphQLError: Argument "size" has invalid value FULL.
Expected type "CoverArtImageSize", found FULL.

But clearly FULL is a valid enum value there. It seems the new null support from #836 didn't extend support to arguments and resulted in breaking what was at least workaround-able.

(I can see how this could indeed pose problems for people when determining "no argument provided" vs. "null/undefined enum value provided", but that seems solvable by checking for 'arg' in args and making sure graphql-js only populates passed-in args.)

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