Skip to content

Validation spec: fields implementation with default values #3214

Closed
@vepanimas

Description

@vepanimas

Hi! I'm the maintainer of the GraphQL for IntelliJ IDEA plugin. I have a question about validating field implementations when a default value is specified. I looked through the specification and found no explicit mention of checking default values in the field validation process.

Should I check default values at all? If so, I know three cases in which it is unclear to me whether the implementation of the interface is correct or should I display an error:

  1. Only an interface specifies a default value, but the implementor doesn't.
interface Interface {
    field(a: String = "1"): String
}

type Query implements Interface {
    field(a: String): String
}
  1. Ony an implementation specifies a default value:
interface Interface {
    field(a: String): String
}

type Query implements Interface {
    field(a: String = "1"): String
}
  1. Both specify default values but their values are different:
interface Interface {
    field(a: String = "ABC"): String
}

type Query implements Interface {
    field(a: String = "1"): String
}

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