This repository was archived by the owner on Sep 3, 2021. It is now read-only.
This repository was archived by the owner on Sep 3, 2021. It is now read-only.
The __resolveType and __isTypeOf resolvers are never called #603
Open
Description
Consider the contrived example below.
- If I replace
makeAugmentedSchema
withmakeExecutableSchema
then everything works as expected. - The
__resolveType
resolver is never called when usingmakeAugmentedSchema
, but is called as expected whenmakeExecutableSchema
is used. - If I use
makeExecutableSchema
and comment out the__resolveType
resolver, then it produces the same error asmakeAugmentedSchema
does in either case (see error below). - Using a
__isTypeOf
resolver has the same issue (is never called withmakeAugmentedSchema
). - Changing the
id
s to something else, as this issue suggests, doesn't help.
Query:
query Vehicle {
vehicle {
__typename
id
}
}
Error:
"Abstract type "Vehicle" must resolve to an Object type at runtime for field "Query.vehicle". Either the "Vehicle" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function."
Schema:
// import { makeExecutableSchema } from 'apollo-server-express';
import { makeAugmentedSchema } from 'neo4j-graphql-js';
export const schema = makeAugmentedSchema({
typeDefs: /* GraphQL */ `
interface Vehicle {
id: ID!
}
type Truck implements Vehicle {
id: ID!
payload: Int
}
type Bus implements Vehicle {
id: ID!
passengers: Int
}
type Query {
vehicle: Vehicle
}
`,
resolvers: {
Vehicle: {
__resolveType(vehicle: { readonly type: 'Truck' | 'Bus' }) {
console.log('__resolveType', vehicle);
return vehicle.type;
},
},
Truck: {
id() {
console.log('Truck ID');
return 'Truck ID';
},
},
Bus: {
id() {
console.log('Bus ID');
return 'Bus ID';
},
},
Query: {
vehicle() {
const type = Math.random() > 0.5 ? 'Truck' : 'Bus';
console.log('type', type);
return {
type,
};
},
},
},
});
Metadata
Metadata
Assignees
Labels
No labels