Skip to content

Instantly share code, notes, and snippets.

@djibe
Last active February 7, 2023 19:05
Show Gist options
  • Save djibe/78ea428dc0050b09d4ccc62a05bea96d to your computer and use it in GitHub Desktop.
Save djibe/78ea428dc0050b09d4ccc62a05bea96d to your computer and use it in GitHub Desktop.
Simplest URQL client demo
// Requires Node 18+, plays witk PokeApi GraphQL beta

import { createClient } from '@urql/core';

const client = createClient({
  url: 'https://beta.pokeapi.co/graphql/v1beta'
});

const query = `
  query {
    pokemon_v2_versiongroup {
      name
    }
  }
`;

const results = await client.query(query)
.toPromise()
.then(result  => {
  console.log(result.data.pokemon_v2_versiongroup)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment