Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active December 7, 2022 14:34
Show Gist options
  • Save MichaelDimmitt/cfe58b79c5c363be51a8de09bc9b00e2 to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/cfe58b79c5c363be51a8de09bc9b00e2 to your computer and use it in GitHub Desktop.
getting started , meetup graph ql

Meetup api shut down rest

and the graph ql docs are not good

https://www.meetup.com/api/guide/#graphQl-guide

The out of the box example does not work.
However, this version is works:

query='query { self { id name } }'
YOUR_TOKEN='put-a-token'
curl -X POST https://api.meetup.com/gql \
  -H "Authorization: Bearer $YOUR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d @- <<EOF
    {"query": "$query"}
EOF

expected output:
{"data":{"self":{"id":"1234567","name":"Example User"}}}

https://www.meetup.com/api/oauth/list/

@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented Feb 13, 2022

query upcoming events:

query='query { self { id name upcomingEvents { pageInfo { startCursor } count edges { node { title } } } } }'

@MichaelDimmitt
Copy link
Author

it will look something like this in javascript
however, you need a server up, oauth tokens in place, and an authenticated token for it to work.

queryFetch(`
  self {
    id
    name
  }
`)
.then(console.log)

function queryFetch(query, variables) {
  const YOUR_TOKEN = "add-token-here"
  return fetch('https://api.meetup.com/gql/', {
    method: 'POST',
    headers: { "Content-Type": "application/json", "Authorization": `Bearer ${YOUR_TOKEN}` },
    body: JSON.stringify({
      query: query,
    })
  }).then(res => res.json())
}

@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented Feb 14, 2022

Summary of how the api schema works for queries:

  1. When you make a request to an object with a type the schema shows fields as required
    note: This does not mean all of them are required you are just required to have a single one of those values present.

  2. You need to keep nesting down until the required field is a primitive type or has all fields not required.
    note: If you fail to do this you will get an error and your entire query will not work.

@MichaelDimmitt
Copy link
Author

SMH, this does not work client side because gql request is not cors enabled ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment