ObjectType implementing InterfaceType doesn't end up in the schema
See original GitHub issueConsider this code:
const {
GraphQLID,
GraphQLInterfaceType,
GraphQLNonNull,
GraphQLObjectType,
GraphQLSchema,
printSchema,
} = require('graphql')
const NodeType = new GraphQLInterfaceType({
name: 'Node',
fields: {
id: {
type: new GraphQLNonNull(GraphQLID),
},
},
})
class Car {} // Kept brief for demo purpose
const CarType = new GraphQLObjectType({
name: 'Car',
interfaces: [NodeType],
fields: {
id: {
type: new GraphQLNonNull(GraphQLID),
},
},
isTypeOf: value => value instanceof Car,
})
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
node: {
type: NodeType,
args: {
id: {
type: new GraphQLNonNull(GraphQLID),
},
},
resolve: () => new Car(),
},
},
}),
})
console.log(printSchema(schema))
Which gives this output:
interface Node {
id: ID!
}
type Query {
node(id: ID!): Node
}
This is a very simplified demo of the problem I’m running in to. Cars (in this case) don’t have their own queries so they don’t end up in the schema even though you can query for them by the interface they implement.
How can I make them appear in the printed schema?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to resolve interface type in GraphQL schema in test only
This implementation is not used (it uses the interface-specific resolve_type method) but satisfies the requirements of the validation check.
Read more >sangria-graphql/sangria - Gitter
At first, I thought about using a field tag, to tag the field as a preview field, and overriding the fieldFn of the...
Read more >Interfaces - GraphQL Ruby
If you add an object type which implements an interface, but that object type doesn't appear in your schema as a field return...
Read more >Schemas and Types - GraphQL
Character is a GraphQL Object Type, meaning it's a type with some fields. Most of the types in your schema will be object...
Read more >Interfaces | Side Quest: Intermediate Schema Design
Learn how to implement interface types in a GraphQL schema ... An implementing object type can also define any number of additional fields...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Fixed in #1679 by @buoyantair
@CrocoDillon You need to write this: