dgraph-io / dgraph-io/dgraph

Covariant interface field implementations should be allowed as per GraphQL spec

Open
#9,460 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Stale
Dominant language
Go
Stars
21.8k
Forks
1.6k
Avg merge
2d 5h
Merged PRs (30d)
9

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by applying the reproducer schema to a Dgraph instance through the /admin/schema endpoint and compare the rejection with the GraphQL specification's covariant interface-field rule. Trace the schema validation path responsible for checking implemented fields; done means the schema is accepted when an implementation returns a subtype such as DeveloperVacancy! for Vacancy!.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.