0.6.3 • Published 4 years ago

@svelkit/graphql v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@svelkit/graphql

A lightweight GraphQL client for svelte

License Latest Release View changelog Bundle Size

What?

Use GraphQL APIs in svelte the svelte way. Either as readable store or using promises.

Why?

Existing solutions (graphql-svelte, @urql/svelte, and others) didn't provide the API we were looking for, features we would not need or are to heavy.

This solutions focuses on a native svelte API using svelte/store.

Installation

npm install @svelkit/graphql

And then import it:

// using es modules
import { useQuery, gql } from '@svelkit/graphql'

// common.js
const { useQuery, gql } = require('@svelkit/graphql')

Alternatively use UNPKG or jsDelivr packages.

Hotlinking from unpkg: (no build tool needed!)

import { useQuery, gql } from 'https://unpkg.com/@svelkit/graphql?module'

Usage

<script>
  import { initGraphQLClient, useQuery, gql } from '@svelkit/graphql'

  initGraphQLClient({ uri: 'https://swapi.graph.cool/' })

  const films = useQuery(gql`
    query {
      allFilms {
        id
        title
        releaseDate
      }
    }
  `)
</script>

{#if $films.fetching} Loading .. {:else if $films.error} Ups... {$films.error.message} {:else}
<ol>
  {#each $films.data.allFilms as film (film.id)}
  <li>{film.title} - {file.releaseDate}</li>
  {/each}
</ol>
{/if}

Features

Polyfills

  • URL
  • URL#searchParams
  • Object.entries
  • fetch
  • globalThis

License

svelkit is open source software licensed as MIT.

0.6.3

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.4.2

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago