Circular references not supported
truca opened this issue · comments
It is said in the docs that in case of a circular reference of types (i.e. Person has a house and the house has Persons),
Quoted from official documentation
http://graphql.org/docs/api-reference-type-system/
When two types need to refer to each other, or a type needs to refer to itself in a field, you can use a function expression (aka a closure or a thunk) to supply the fields lazily.
I'm currently needing this and i've seen more people in the same situation. Should i do a PR with this or is it currently under development?
if you can do a PR that would be great!
Hello, I cant seem to get this working, the only "docs" y see is in the test cases, I have something like this:
export const TruckType = createType({
name: 'Truck',
class: 'GraphQLObjectType',
schema: truckSchema,
fields: () => ({
trips: {type: new GraphQLList(TripType)},
}),
});
export const TripType = createType({
name: 'Trip',
class: 'GraphQLObjectType',
schema: schema,
extend: {
truck: {type: TruckType},
},
});
But the Truck.trips field is not appearing.
Any idea of how to use this?