OK so I have the following types, with the "Spot" type coming from prisma.
type Query {
SpotDetails(id: ID!, lat: String, long: String, regLocation: String): SpotDetails!
Spots: [Spot!]!
}
type SpotDetails {
info: Spot!
regulations: [SpotRegulation]
}
type SpotRegulation {
regulationNumber: String
generalRegText: String
waters: String
seasons: String
bags: String
notes: String
}
How do I create the resolver where I can query Prisma for a spot by id
and then combine it with the other fields from the SpotRegulation
type? Basically I want to be able to query SpotDetails
.
Right now for the resolver I have the following, but I do not think it is working because the info provided to the Prisma query is the SpotDetails
info and not the Spot
info that it is expecting.
SpotDetails(parent, args, ctx, info) {
let { id } = args;
let details = new Object();
details['info'] = ctx.db.query.spot({ where: { id } }, info);
},
Here is the query I'm using on graphQL playground to test this
query {
SpotDetails(id:"cjkbwq1nm00310a958udjcr20"){
regulations{
notes
}
}
}
So I originally included info because that was used in the example code from GraphQL boilerplate. However after looking at the prisma documents in regards to reading data none of the examples included passing the info. I'm not sure what the info is used for but when I removed it from the spots call in the resolver as shown below it worked as expected. I'll still need to figure out why info was passed but for what I needed to accomplish it was needed.
SpotDetails(parent, args, ctx, info) {
let { id } = args;
let details = new Object();
details['info'] = ctx.db.query.spot({ where: { id } });
return details;
},