Skip to content

stephenbaldwin/graphql-client

Repository files navigation

graphql-client

Example Usage

import GraphQLClient from 'graphql-client';
const schema = require('./schema.gql');

const client = new GraphQLClient(schema, {
  cacheEngine: new GraphQLClient.InMemoryStore(),
  cacheTimeInMs: 1000,
});

const users = await client.query("GetUsersByID", { id: 1 });
const user = await client.mutation("CreateUser", { firstName: "Stephen", lastName: "Baldwin" });

const addresses = await client.query({
  name: "GetUsersAddressByUserID",
  variables: {
    userID: user.id,
  },
});


const externalResult = await GraphQLClient.RawQuery("query Users { users { name } }");

as an express route

app.get('/user/:id', client.route("GetUsersByID"));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published