npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graphql-schema-utils

v0.6.7

Published

Extensions for graphql-js to support diffing and merging types and schemas.

Downloads

15

Readme

graphql-schema-utils

Extensions for graphql-js to support diffing and merging types and schemas.

Getting Started

Install it

npm install --save graphql-schema-utils

Require it

# graphql-js prototypes are automatically extended
require('graphql-schema-utils');

Use it

# Operate on GraphQLSchemas
const thisSchema = buildSchema(...);
const otherSchema = buildSchema(...);
const diffs = schema1.diff(schema2);
const mergedSchema = schema1.merge(schema2);
# Operate on GraphQL types
const thisType = new GraphQLObjectType(...);
const otherType = new GraphQLObjectType(...);
const diffs = thisType.diff(otherType);
const mergedType = thisType.merge(otherType);

API Docs

Classes

Constants

GraphQLSchema

GraphQL schema.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/schema.js

graphQLSchema.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLSchema and another one by diffing all of the types.

Kind: instance method of GraphQLSchema
Returns: Array.<GraphQLDiff> - array of differences between the schemas

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLSchema | | another GraphQLSchema | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this schema" | specifies a custom name to refer to the schema on which .diff(...) was called. | | [options.labelForOther] | String | "other schema" | specifies a custom name to refer to the schema against which this schema is being diffed. |

graphQLSchema.merge(other) ⇒ GraphQLSchema

Merge this GraphQLSchema with another one. This schema's types and fields take precedence over other's. Does not modify either schema, but instead returns a new one.

Kind: instance method of GraphQLSchema
Returns: GraphQLSchema - new GraphQLSchema representing this merged with other

| Param | Type | Description | | --- | --- | --- | | other | GraphQLSchema | another GraphQLSchema to merge with this one |

GraphQLUnionType

GraphQL union type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLUnionType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLUnionType and another GraphQLUnionType.

Kind: instance method of GraphQLUnionType
Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLUnionType | | another GraphQLUnionType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

graphQLUnionType.merge(other) ⇒ GraphQLUnionType

Merges this GraphQLUnionType with another GraphQLUnionType by taking the union of the types included in both.

Kind: instance method of GraphQLUnionType
Returns: GraphQLUnionType - a new GraphQLUnionType resulting from merging this and other

| Param | Description | | --- | --- | | other | another GraphQLUnionType to merge with this one |

GraphQLObjectType

GraphQL object type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLObjectType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType and another. Fields and implemented interfaces are compared.

Kind: instance method of GraphQLObjectType Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | | another GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

graphQLObjectType.merge(other) ⇒ GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType

Merges another GraphQLObjectType or GraphQLInterfaceType with this one by taking the union of all fields in both types, overwriting this type's fields with the other's if there are conflicts. For GraphQLObjectTypes, implemented interfaces are also merged.

Kind: instance method of GraphQLObjectType Returns: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType - a new graphql type resulting from merging this and other

| Param | Description | | --- | --- | | other | another GraphQL type to merge with this one |

GraphQLInterfaceType

GraphQL interface type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLInterfaceType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType and another. Fields and implemented interfaces are compared.

Kind: instance method of GraphQLInterfaceType Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | | another GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

graphQLInterfaceType.merge(other) ⇒ GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType

Merges another GraphQLObjectType or GraphQLInterfaceType with this one by taking the union of all fields in both types, overwriting this type's fields with the other's if there are conflicts. For GraphQLObjectTypes, implemented interfaces are also merged.

Kind: instance method of GraphQLInterfaceType Returns: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType - a new graphql type resulting from merging this and other

| Param | Description | | --- | --- | | other | another GraphQL type to merge with this one |

GraphQLScalarType

GraphQL scalar type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLScalarType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLScalarType and another.

Kind: instance method of GraphQLScalarType
Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLScalarType | | another GraphQLScalarType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

GraphQLEnumType

GraphQL enum type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLEnumType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLEnumType and another. The name and enum values are compared.

Kind: instance method of GraphQLEnumType
Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLEnumType | | another GraphQLEnumType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

graphQLEnumType.merge(other) ⇒ GraphQLList | GraphQLNonNull | GraphQLScalarType | GraphQLEnumType

Merges a type by simply overwriting this type with other if it exists.

Kind: instance method of GraphQLEnumType
Returns: GraphQLList | GraphQLNonNull | GraphQLScalarType | GraphQLEnumType - other if it exists, otherwise this.

| Param | Type | Description | | --- | --- | --- | | other | GraphQLList | GraphQLNonNull | GraphQLScalarType | GraphQLEnumType | another GraphQL type object to merge with this |

GraphQLInputObjectType

GraphQL input object type.

Kind: global external
See: https://github.com/graphql/graphql-js/blob/master/src/type/definition.js

graphQLInputObjectType.diff(other, [options]) ⇒ Array.<GraphQLDiff>

Reports differences between this GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType and another. Fields and implemented interfaces are compared.

Kind: instance method of GraphQLInputObjectType
Returns: Array.<GraphQLDiff> - array of differences

| Param | Type | Default | Description | | --- | --- | --- | --- | | other | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | | another GraphQLObjectType, GraphQLInterfaceType, or GraphQLInputObjectType | | [options] | Object | | optional properties to modify the behavior of the diff operation | | [options.labelForThis] | String | "this type" | specifies a custom name to refer to the object on which .diff(...) was called. | | [options.labelForOther] | String | "other type" | specifies a custom name to refer to the object against which this object is being diffed. |

graphQLInputObjectType.merge(other) ⇒ GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType

Merges another GraphQLObjectType or GraphQLInterfaceType with this one by taking the union of all fields in both types, overwriting this type's fields with the other's if there are conflicts. For GraphQLObjectTypes, implemented interfaces are also merged.

Kind: instance method of GraphQLInputObjectType
Returns: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType - a new graphql type resulting from merging this and other

| Param | Description | | --- | --- | | other | another GraphQL type to merge with this one |

GraphQLDiff

Object containing metadata about a diff between two GraphQL types.

Kind: global class

new GraphQLDiff(thisType, otherType, diffType, description, backwardsCompatible)

Create a new instance of a GraphQLDiff, containing metadata about a difference between two GraphQL types.

| Param | Type | Description | | --- | --- | --- | | thisType | GraphQLObjectType | GraphQLScalarType | GraphQLEnumType | GraphQLNonNull | GraphQLList | GraphQLUnionType | the GraphQL type instance on which the diff method was executed | | otherType | GraphQLObjectType | GraphQLScalarType | GraphQLEnumType | GraphQLNonNull | GraphQLList | GraphQLUnionType | the GraphQL type instance which was compared to thisType | | diffType | string | the specific kind of difference between thisType and otherType | | description | string | | | backwardsCompatible | boolean | true if this is a non-breaking change when interpreted as thisType changing to otherType |

DiffType : Object

Constants representing valid types of GraphQLDiffs.

Kind: global constant