You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
Perhaps this is user error, but is the following schema valid?
Yes, it's invalid. The problem here is that buildSchema silently ignores extensions so nickname is never added. It's already reported in #922 and I finishing adding support for extensions and it will be included in upcoming 15.0.0-alpha.0 (ETA later this week).
Meanwhile you wan workaround using extendSchema:
var { graphql, buildSchema, extendSchema, parse, printSchema } = require("graphql");
// Construct a schema, using GraphQL schema language
var schema = buildSchema(`
type Query {
hello: Person
}
interface NamedEntity {
fullName: String
}
type Person implements NamedEntity {
isCool: Boolean
fullName: String
}
`);
schema = extendSchema(schema, parse(`
extend interface NamedEntity {
nickname: String
}
`));
var root = {
hello: () => {
return { isCool: true };
}
};
graphql(schema, "{ hello { isCool } }", root).then(response => {
console.log(response);
});
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:
yet, it executes with no problems. Rolling the
nickname
field into the originalNamedEntity
portion, and removing the extension (see below) does result in a schema validation error.So my question is, despite being a bit of a contrived example, is this a bug?
The text was updated successfully, but these errors were encountered: