graphql-schemax
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.0.5](https://github.com/nicolasdao/graphql-schemax/compare/v0.0.4...v0.0.5) (2021-10-21) | ||
### Features | ||
* Add constructor support for array of inline schema definitions ([23976ce](https://github.com/nicolasdao/graphql-schemax/commit/23976ce9999d705131297c97988ff2bcefa8d041)) | ||
### [0.0.4](https://github.com/nicolasdao/graphql-schemax/compare/v0.0.3...v0.0.4) (2021-10-21) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "graphql-schemax", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Creates GraphQL string schema from plain JSON objects.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
106
README.md
@@ -7,3 +7,3 @@ # GRAPHQL-SCHEMAX | ||
- Inspection: Easily traverse the schema tree. | ||
- Leaner: Define GraphQL types, enums and inputs on-the-fly instead of having to define them explicitly. | ||
- Leaner: Define GraphQL types, enums and inputs on-the-fly (_anonymous types_) instead of having to define them explicitly. | ||
@@ -433,9 +433,109 @@ This package works with both ES6 modules and CommonJS and contains no dependencies. | ||
# Manipulating schemas | ||
## Merging schemas | ||
# APIs | ||
## `constructor` | ||
The `Schemax` class supports an undefined amount of arguments. It supports an inline schema definitions as well as arrays of inline schema definitions. | ||
__*Inline schema definitions*__ | ||
```js | ||
import { Schemax } from 'graphql-schemax' | ||
const schema = new Schemax( | ||
'type Project', { | ||
id: 'ID', | ||
name: 'String' | ||
}, | ||
'type User', { | ||
id: 'ID', | ||
first_name: 'String', | ||
last_name: 'String' | ||
}, | ||
'type Query', { | ||
projects: '[Project]', | ||
users: '[User]' | ||
} | ||
) | ||
console.log(schema.toString()) | ||
``` | ||
Which can also be written as follow: | ||
```js | ||
import { Schemax } from 'graphql-schemax' | ||
const inlineSchema = [ | ||
'type Project', { | ||
id: 'ID', | ||
name: 'String' | ||
}, | ||
'type User', { | ||
id: 'ID', | ||
first_name: 'String', | ||
last_name: 'String' | ||
}, | ||
'type Query', { | ||
projects: '[Project]', | ||
users: '[User]' | ||
}] | ||
const schema = new Schemax(...inlineSchema) | ||
console.log(schema.toString()) | ||
``` | ||
__*Array schema definitions*__ | ||
```js | ||
import { Schemax } from 'graphql-schemax' | ||
const inlineSchema = [ | ||
'type Project', { | ||
id: 'ID', | ||
name: 'String' | ||
}, | ||
'type User', { | ||
id: 'ID', | ||
first_name: 'String', | ||
last_name: 'String' | ||
}, | ||
'type Query', { | ||
projects: '[Project]', | ||
users: '[User]' | ||
}] | ||
const schema = new Schemax(inlineSchema) | ||
console.log(schema.toString()) | ||
``` | ||
or | ||
```js | ||
import { Schemax } from 'graphql-schemax' | ||
const inlineSchema = [ | ||
'type Project', { | ||
id: 'ID', | ||
name: 'String' | ||
}, | ||
'type User', { | ||
id: 'ID', | ||
first_name: 'String', | ||
last_name: 'String' | ||
}, | ||
'type Query', { | ||
projects: '[Project]', | ||
users: '[User]' | ||
}] | ||
const schema = new Schemax(inlineSchema) | ||
console.log(schema.toString()) | ||
``` | ||
# FAQ | ||
## How to merge schemas? | ||
# Dev | ||
@@ -442,0 +542,0 @@ ## About this project |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35109
542
593