Skip to content

Spec Bug...? ProvidedRequiredArgumentsRule fails to evaluate all potential runtime types #1121

Open
@yaacovCR

Description

@yaacovCR

Consider the following schema:

type Query {
  someInterface: SomeInterface
}

interface SomeInterface {
  echo(value: String! = "default"): String
}

type SomeType implements SomeInterface {
  echo(value: String!): String
}

As mentioned by @vepanimas at graphql/graphql-js#3214 => types implementing interfaces have to conform to their types, but not to their default values, and so the above is now considered valid.

Consider the following operation:

{
  someInterface {
    echo
  }
}

The ProvidedRequiredArgumentsRule as specified and implemented within the reference evaluation states that an argument for echo on SomeInterface is not required, because a default value exists, but at runtime, the execution portion of the spec and the implementation take default values from the concrete runtime type, ignoring the interface. The operation will validate successfully, but throw a runtime error.

Thoughts:

  1. We either should (A) not allow default values on interface fields (because they are currently apparently never used) or (B) require that implementing types also have default values.
  2. We can solve the validation/execution discrepancy either via option (B), or by (Z) changing the Validation Rule to inspect all the possible runtime types.

I think option (B) is a breaking change in terms of 1, because some schemas will break.
I think fixing the validation rule via option (B) or (Z) may also be a breaking change in terms of 2, because some operations will break => but does it count if it is a bug fix? Seems like it does, similar to #1059

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