smallorange-graphql-mux

GraphQL multiplex

Usage no npm install needed!

<script type="module">
  import smallorangeGraphqlMux from 'https://cdn.skypack.dev/smallorange-graphql-mux';
</script>

README

CircleCI

Usage

    const http = json => fetch('http://yourGraphQLEndpoint.com', {
        method: 'POST',
        cache: 'no-store',
        headers: {
            'content-type': 'application/json'
        },
        body: JSON.stringify(json)
    });
    
    const queue = new GraphQLMux(http, 'query', 10);
    
    queue.graphql({
        requestString: `query($user: String!) {
            user(id: $user) {
                name
            }
        }`,
        variableValues: {
            user: 'user'
        }
    })
    .then(...);
    
    queue.graphql({
        requestString: `query(order: String!) {
            order(id: $order) {
                date
                total
            }
        }`,
        variableValues: {
            order: 'order'
        }
    })
    .then(...);