Skip to content

Covariant interface field implementations should be allowed as per GraphQL spec #9460

@PCavan

Description

@PCavan

Describe the bug

With respect to what constitutes a valid type, the GraphQL spec states that for each field on a type corresponding to a field on an implemented interface:

field must return a type which is equal to or a sub-type of (covariant) the return type of implementedField field’s return type

Dgraph's implementation of GraphQL does not allow such covariant field implementation.

To Reproduce

Attempt to apply the following GraphQL schema to a Dgraph instance (POST to /admin/schema):

interface Vacancy {
    roleName: String!
}

type DeveloperVacancy implements Vacancy {
    roleName: String!
    requiredLanguages: [String!]!
}

type DesignerVacancy implements Vacancy {
    roleName: String!
}

interface Application {
    vacancy: Vacancy!
}

type DeveloperApplication implements Application {
    vacancy: DeveloperVacancy!
    knownLanguages: [String!]!
}

type DesignerApplication implements Application {
    vacancy: DesignerVacancy!
    portfolioUrl: String!
}

Expected behavior

Schema is successfully applied to Dgraph instance.

Screenshots

An error message is returned:

resolving updateGQLSchema failed because input:19: For type DeveloperApplication to implement interface Application the field vacancy must have type Vacancy!\n (Locations: [{Line: 3, Column: 4}])

Environment

  • Docker image dgraph/standalone:v25.0.0-preview6

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