Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junosuarez/graphql-schema-version
derive a semver version number from a graphql schema
https://github.com/junosuarez/graphql-schema-version
Last synced: 8 days ago
JSON representation
derive a semver version number from a graphql schema
- Host: GitHub
- URL: https://github.com/junosuarez/graphql-schema-version
- Owner: junosuarez
- License: isc
- Created: 2016-09-22T23:37:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-11-05T17:28:15.000Z (about 3 years ago)
- Last Synced: 2024-08-09T12:27:12.540Z (3 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# graphql-schema-version
derive a semver version number from a graphql schema[![Build Status](https://travis-ci.org/jsdnxx/graphql-schema-version.svg?branch=master)](https://travis-ci.org/jsdnxx/graphql-schema-version)
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)## usage
```js
const graphqlSchemaVersion = require('graphql-schema-version')const newSchema = require('./newClientSchema.json')
const oldSchema = require('./oldClientSchema.json')
const oldVersion = '2.3.0'
console.log(graphqlSchemaVersion(newSchema, oldSchema, oldVersion))
```
prints a semver for the relation, e.g. `2.4.0` for a minor version increment or `3.0.0` for major.the schema documents it takes as arguments are the JSON documents generated from the client introspection query - see http://graphql.org/graphql-js/utilities/#printintrospectionschema
### Spec
graphql-schema-version
✓ returns oldVersion if no old schema is supplied
✓ defaults to `1.0.0` if oldVersion is not supplied
✓ increments patch version if field is deprecated
✓ increments minor version if enum type is added
✓ increments minor version if enum value is added
✓ increments minor version if type is added
✓ increments major version if type is deleted
✓ increments minor version if field is added
✓ increments major version if field is deleted
✓ increments major version if field type changed
✓ increments minor version if field argument added
✓ increments major version if field argument deleted
✓ increments major version if field argument type changed
✓ increments patch version if directive is added
✓ increments major version if directive is deleted
✓ increments major version if enum type is deleted
✓ increments major version if enum value is deleted
✓ increments minor version if field type changes from non-nullable to nullable of the same inner type## installation
$ npm install graphql-schema-version
## running the tests
From package root:
$ npm install
$ npm test## contributors
## todo
- [ ] rewrite with proper visitor pattern for maintainability## license
ISC. (c) MMXVI [email protected]. See LICENSE.md