Skip to content

Invalid schmea with interface extension does not fail #2199

Closed
@realdoug

Description

@realdoug

Perhaps this is user error, but is the following schema valid? Based on my reading of the language spec, this program should fail with a validation exception:

var { graphql, buildSchema, printSchema } = require("graphql");

// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
  type Query {
    hello: Person
  }

  interface NamedEntity {
    fullName: String
  }

  extend interface NamedEntity {
    nickname: String
  }

  type Person implements NamedEntity {
    isCool: Boolean
    fullName: String
  }
`);


var root = {
  hello: () => {
    return { isCool: true };
  }
};

graphql(schema, "{ hello { isCool } }", root).then(response => {
  console.log(response);
});

yet, it executes with no problems. Rolling the nickname field into the original NamedEntity portion, and removing the extension (see below) does result in a schema validation error.

  type Query {
    hello: Person
  }

  interface NamedEntity {
    fullName: String
    nickname: String
  }

  type Person implements NamedEntity {
    isCool: Boolean
    fullName: String
  }

So my question is, despite being a bit of a contrived example, is this a bug?

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