lokka-transport-http-querystring

Isomorphic HTTP Transport for Lokka that uses query string instead of POST body

Usage no npm install needed!

<script type="module">
  import lokkaTransportHttpQuerystring from 'https://cdn.skypack.dev/lokka-transport-http-querystring';
</script>

README

lokka-transport-http-querystring

Isomorphic HTTP Transport Layer for Lokka. Uses a query string in conjunction with a GET request to facilitate CORS


This is a graphql-express compatible transport layer for Lokka.

Basic Usage

Install the package:

npm i --save lokka-transport-http-querystring
npm i --save lokka

This is how to send request to Facebook's SWAPI GraphQL Demo.

import HttpTransport from 'lokka-transport-http-querystring';
const transport = new HttpTransport('http://graphql-swapi.parseapp.com/');
transport.send(`
    {
      allFilms {
        films {
          title
        }
      }
    }
`).then(response => {
    console.log(JSON.stringify(response, null, 2));
});

Send Custom Headers

It's possible to send custom headers like this:

const headers = {
    'my-headers': 'some-value'
};
const transport = new HttpTransport('/graphql', {headers});

Authentication

This package does not handle authentication information for you. But it'll let you interact with your app's existing authentication mechanism.