Happy use Graphql without crab
ES5
const gql = require("graphql-crab");
ES6
import gql from "graphql-crab";
Browser
var gql = GraphqlCrab;
const query = gql`
query($user: User, $page: Int, $perPage: Int) {
getUser(input: $user) {
userId
name
age
}
}
`
const payload = query.user({name: "Tim"}).page(1).perPage(10).toJSON()
payload
{
"query": `query($user: User, $page: Int, $perPage: Int) {
getUser(input: $user) {
userId
name
age
}
}`,
"variables": {
"user": {
"name": "Timothy",
},
"page": 1,
"perPage": 10,
},
}