JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q42530F
  • License MIT

Package Exports

  • lazy-gql
  • lazy-gql/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lazy-gql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gql builder

Npm package for fast app prototyping

Motivation

For fast prototyping next.js app with Hasura as backend Library is abstruction layer ower Hasura query api

How to use

  1. Create dataSchema file, minimum example
export default {
  user: {
    id: { },
    name: { },
    email: { },
  },
}
  1. Fill internal library store with setTableKeys
import { setTableKeys } from 'gql-builder'
import dataSchema from 'dataSchema'

setTableKeys(dataSchema)
  1. Call one of build methods

Examples

graphql-request for backend use example(with next.js api routes)

import { GraphQLClient, gql } from 'graphql-request'
import dataSchema from 'dataSchema'
import { setTableKeys } from 'gql-builder'

setTableKeys(dataSchema)

const runQuery = async (query, variables) => {
  const client = new GraphQLClient(process.env.URL, {
    headers: {

    },
  })

  return await client.request(query, variables)
}

const request = async (q, ...args) => {
  const { query, mutation, variables, extendVariablesKeys } = q

  return await runQuery(
    gql`
      ${query || mutation}
    `,
    extendVariablesKeys(variables(...args))
  )
}

export default request
import request from 'request'
import { buildInsert } from 'gql-builder'

const handler = async (req) => {
  return await request(buildInsert('users'), [{
    name: 'random name',
    email: 'random@email',
  }])
}

export default handler

API