A pure library to convert json objects into graphql queries
It refers to a representation of the parameters that can be passed to an object.
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
- Array and can be represented by listing each filed and its arguments and fields
A simpler solution so each name mapped to its value. But, fields must be mapped to something. (empty fields or arguments are ignored btw)
Example:
GraphqlQuery({
field0: true,
field1: {
subfield0: true,
subfield1: {
// Sub Subfields
},
subfield2: [{/* Arguments */}, {
// Sub Subfields
}]
},
field2: [{/* Arguments */}, {
subfield0: true,
subfield1: {
// Sub Subfields
},
subfield2: [{/* Arguments */}, {
// Sub Subfields
}]
}]
})
Another solution for shorter queries. Since you can pass the name of fields without associating it to something. (empty fields and arguments are ignored here too)
Example:
GraphqlQuery([
'field0',
['field1', [
'subfield0',
['subfield1', [
// Sub subfields
]],
['subfield2', {/* Arguments */}, [
// Sub subfields
]]
]],
['field2', {/* Arguments */}, [
'subfield0',
['subfield1', [
// Sub subfields
]],
['subfield2', {/* Arguments */}, [
// Sub subfields
]]
]]
])
- The two styles are interchangeable, and one style can be nested in another
- Written in typescript
- Natively supports the browser
You can install this via NPM with:
npm install
You can install it in the browser by adding this tag:
<script src="https://unpkg.com/[email protected]/build/index.js" type="module"></script>