Good afternoon.
I have 2 collections in mongoDB with a one-to-many relationship, where one of the collections receives the foreign key of the other.
const Sport = mongoose.model('Sport', new Schema({
_id: {
type: String,
default:() => uuid()
},
name: { type: String, required: true }
}))
const Event = mongoose.model('Event', new Schema({
_id: {
type: String,
default:() => uuid()
},
name: { type: String, required: true },
sport_id: { type: String, required: true }
}))
I want to do searches on these collections with graphql and when searching for Event, show the data from 'sport_id' instead of just showing the String. How do I do? How do I make the rootvalue?
type Sport {
_id: String
name: String
}
type Event {
_id: String
name: String
sport_id: Sport
}
type Query {
sport(name: String): [Sport!]
sportById(_id: String): Sport
event(name: String, sport_id: String): Event!
eventById(_id: String): Event
}