charlypoly / spotify-graphql

GraphQL schema for Spotify WebAPI — TypeScript / Node.js (v6)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parameters / variables example

jopek opened this issue · comments

Hello!

is there a way to pass in $variables?
I was trying the following and it craps out. :/

SpotifyGraphQLClient(config)
  .query(`
      {
        playlist(userId: "1128723762", id: $plid) {
          id
          uri
          name
        }
      }`, null, null, { plid: "2YARXniaJywrRZbbQeSoAi" })
  .then(res => {
    console.log(JSON.stringify(res, null, 2));
    return res;
  })

gives the error

"message": "Variable \"$plid\" is not defined.",

I did not find any examples or tests about passing variables. could you help?

i figured it out. one has to define the variable...

SpotifyGraphQLClient(config)
  .query(`query playlist($plid: String!)
      {
        playlist(userId: "1128723762", id: $plid) {
          id
          uri
          name
        }
      }`, null, null, { plid: "2YARXniaJywrRZbbQeSoAi" })