I have like this:
//driverType.js
module.exports = new GraphQLObjectType({
name: 'Driver',
fields: () => ({
homeTerminal: {
type: TerminalType,
resolve: resolver(User.HomeTerminal)
}
})
});
and this:
//terminalType.js
module.exports = new GraphQLObjectType({
name: 'Terminal',
fields: () => ({
drivers: {
type: new GraphQLList(DriverType),
resolve: resolver(Terminal.Drivers)
}
})
});
I get the error:
Error: Schema must contain unique named types but contains multiple types named "Driver".
I found some posts that say that wrapping the fields in a function block will solve it, but as you can see I did that, and it didn't make a difference.
Thins kind of cyclic reference should be supported, yes? We can let the client will specify the desired depth.
What am I doing wrong?
As a workaround, I could remove homeTerminal
from DriverType and flatten it with primitive fields, but that's rather inelegant.
drivers
fromTerminalType
the error goes away. If I removehomeTerminal
fromDriverType
it does not go away. I suppose that's a clue. – Tim ScottGraphQLObjectType
with name of "Driver". – Tim Scott