@cjenaro/fetchql

A GraphQL wrapper for browser's fetch

Usage no npm install needed!

<script type="module">
  import cjenaroFetchql from 'https://cdn.skypack.dev/@cjenaro/fetchql';
</script>

README

fetchql

A GraphQL wrapper for the browsers native fetch.

Example:

fetchql(
    "https://rickandmortyapi.com/graphql/",
    gql`
      query CHARACTERS($name: String!) {
        characters(filter: { name: $name }) {
          results {
            id
            name
            status
            species
            type
            origin {
              name
            }
            image
          }
        }
      }
    `,
    {
      name,
    }
  ).then(
    (data) => {
      console.log(data);
    },
    (error) => {
      console.log(error);
    }
  );