I have two separate working calls, defined below, which I am trying to figure out how to combine. The schema is specific to Meetup API, but I think general GraphQL-fu can help here!
N
Event IDsquery($query:String!,$lat: Float!,$lon:Float!,$radius:Int!) {
keywordSearch(filter: {query: $query,lat: $lat, lon: $lon, radius:$radius source:EVENTS, eventType:PHYSICAL}) {
count
edges{
node{
id
}
}
}
}
As a sample query:
{"query":"knitting ","lat":37.774929,"lon":-122.419418,"radius":50}
Here are the results (knitting meetups are not that common in San Francisco):
{
"data": {
"keywordSearch": {
"count": 3,
"edges": [
{
"node": {
"id": "281538648!chp"
}
},
{
"node": {
"id": "281467251!chp"
}
},
{
"node": {
"id": "281455979!chp"
}
}
]
}
}
}
id
returned in Call 1 query($eventId: ID) {
event(id: $eventId) {
... bare_event
}
}
fragment bare_event on Event{
title
dateTime
eventUrl
onlineVenue{
type
url
}
venue{
... bare_venue
}
}
fragment bare_venue on Venue{
id
name
address
}
So, for example, grabbing the first ID from Call1, using {"eventId":"281538648!chp"}
, we get
{
"data": {
"event": {
"title": "Monday Knitting Meetup (Mountain View)",
"dateTime": "2021-10-25T19:00-07:00",
"eventUrl": "https://www.meetup.com/scv-knitters/events/281538648",
"onlineVenue": null,
"venue": {
"id": "25006220",
"name": "Panera Bread (YET ANOTHER PANERA!!)",
"address": "1035 El Monte Ave"
}
}
}
}
How do we have that Call 2 verbose event information included in call 1, along with each event ID?
I think the point of GraphQL is so that I would not have to make N+1
queries for fetching additional information for N
items related from a search list (I'm new!)
How do you combine these two calls into one query, so that in additional to pulling only the event ID, I can also pull other event information, for each of the search listings?
This is the query and how to fetch the data
query ($query: String!, $lat: Float!, $lon: Float!, $radius: Int!) {
keywordSearch(
filter: {query: $query, lat: $lat, lon: $lon, radius: $radius, source: EVENTS, eventType: PHYSICAL}
) {
count
edges {
node {
id
result {
... on Event {
title
dateTime
eventUrl
onlineVenue {
type
url
}
venue {
id
name
address
}
}
}
}
}
}
}
{
"query": "knitting ",
"lat": 37.774929,
"lon": -122.419418,
"radius": 50
}