graphql-query-builder-ts
v0.2.7
Published
A package to help smooth the process of building GraphQL queries in Typescript
Downloads
4
Readme
GraphQl query builder with TS type support
Installation
npm install --save graphql-query-builder-ts
Getting started
After install run:
npm exec graphql-query-builder-ts -- --init
Every time your schema changes run:
npm exec graphql-query-builder-ts -- --update
Usage
Simple usage:
import queryBuilder from "graphql-query-builder-ts";
const query = queryBuilder("query", {
menu: {
args: {
_id: "654321",
},
fields: ["_id", { products: ["_id"] }],
},
});
Multiple or the same query/mutation:
import queryBuilder from "graphql-query-builder-ts";
const query = queryBuilder("query", {
menu: [
{
alias: "menu1",
args: {
_id: "654321",
},
fields: ["_id", { products: ["_id"] }],
},
{
alias: "menu2",
args: {
_id: "654321",
},
fields: ["_id", { products: ["_id"] }],
},
],
});