Having trouble figuring out how/where to get subschema
for delegateToSchema
.
I have 2 schemas in separate files which I am merging using mergeTypeDefs
:
# booking schema
type Booking {
id
name
}
type Query {
booking(id: Int!): Booking
}
and the other schema:
# user schema
type User {
id: Int!
name: String!
bookingId: Int!
booking: Booking
}
type Query {
users: [User]
}
I want to use delegateToSchema so I don't have to resolve booking
field manually for my User
type, so I was trying this in my resolvers:
export const resolvers = {
Query: { ... }
User: {
booking: (parent, args, context, info) => delegateToSchema({
schema: subschema // <<< how do I get this?
operation: 'query',
fieldName: 'booking',
args: { id: parent.booking_id },
context,
info
})
}
}
I have tried to use loadSchema
but no luck.
NOTE: all 3 are in separate files