Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
/ gql-query Public archive

A pure library to convert json objects into graphql queries

License

Notifications You must be signed in to change notification settings

cufyorg-archive/gql-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphql Query

A pure library to convert json objects into graphql queries

Types

Arguments

It refers to a representation of the parameters that can be passed to an object.

Fields

It refers to a representation of the fields of an object, and can be presented in two ways:

  • Object and can be represented by mapping each field to its arguments and fields

Object Fields

A simpler solution so each name mapped to its value. But, fields must be mapped to something. (empty fields or arguments are ignored and fields starting with $ are formatted as is)

Example:

formatGraphqlQuery({
    field0: true,
    field1: {
        subfield0: true,
        subfield1: {
            // Sub Subfields
        },
        subfield2: [{/* Arguments */}, {
            // Sub Subfields
        }]
    },
    field2: [{/* Arguments */}, {
        subfield0: true,
        subfield1: {
            // Sub Subfields
        },
        subfield2: [{/* Arguments */}, {
            // Sub Subfields
        }]
    }]
})

Features

  • The two styles are interchangeable, and one style can be nested in another
  • Written in typescript
  • Natively supports the browser

Node install

You can install this via NPM with:

  npm install

Browser Install

You can install it in the browser by adding this tag (replace TAG with the version):

<script src="https://cdn.jsdelivr.net/gh/cufyorg-archive/gql-query@TAG/build/index.js" type="module"></script>

About

A pure library to convert json objects into graphql queries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published