On this page

@graphql-inspector/core

Changelog for @graphql-inspector/core: every release with its changes and the pull requests behind them.

8.1.5

Patch Changes

  • #2999 3e5344e Thanks @eddeee888! - DIRECTIVE_ARGUMENT_ADDED now takes the argument’s default value into account, the same way FIELD_ARGUMENT_ADDED does. Adding an argument with a default value to an existing directive is reported as DANGEROUS instead of BREAKING (non-null) or NON_BREAKING (nullable). Adding a non-null argument without a default value is still BREAKING.

  • #3012 1b386ed Thanks @eddeee888! - Fix coverage() root operation stats so each root field is counted once and custom root type names are supported.

8.1.4

Patch Changes

  • #3003 877ad2b Thanks @n1ru4l! - Report FIELD_ARGUMENT_DEFAULT_CHANGED (and the directive/input field equivalents) when a nested input field default changes on GraphQL 17, matching GraphQL 16 behavior.

8.1.3

Patch Changes

  • #3006 2820dd8 Thanks @n1ru4l! - Speed up diff with the simplifyChanges rule for large schema additions. The changes nested under an added type or directive (its fields, arguments, directive usages, …) are no longer computed, since simplifyChanges removes them anyway. The result is unchanged, but rules that run before simplifyChanges no longer receive these nested changes.

8.1.2

Patch Changes

  • #3004 a24f2d2 Thanks @n1ru4l! - Speed up the simplifyChanges diff rule for large additions, such as a new type with many fields.

8.1.1

Patch Changes

  • #2998 ab6b90d Thanks @eddeee888! - coverage() no longer throws when a document selects the __type introspection field. All __-prefixed meta-fields (__typename, __schema, __type) are skipped.

  • #3001 c5dbf87 Thanks @n1ru4l! - Improve diff() performance on schemas with many directive usages (e.g. federation supergraphs). Directive argument values are now compared structurally instead of printing both AST values to strings.

  • #3002 9c84845 Thanks @n1ru4l! - Speed up diff() for large schemas where most of the schema is unchanged (e.g. federation supergraphs). Unchanged fields are now skipped with a single cheap check, and unchanged directive usages, lists, type references and scalar/enum default values are detected without allocating intermediate maps, strings or coerced values.

8.1.0

Minor Changes

  • #2987 6a147fc Thanks @eddeee888! - diff no longer reports directive usages, such as @deprecated, as added or removed when one of the two schemas has no AST (for example, it was built from introspection). Those comparisons are skipped for the whole diff. When exactly one schema has an AST, the new optional onWarning option is called once with { message }, which the CLI and GitHub Action print as a warning.

8.0.3

Patch Changes

  • #2991 70745e6 Thanks @jdolle! - FIELD_ARGUMENT_ADDED now reports a nullable argument without a default value, added to an existing field, as NON_BREAKING instead of DANGEROUS: existing operations stay valid and the field receives no value for the argument, exactly as before. The other cases are unchanged: a non-null argument without a default value is BREAKING, and any argument with a default value is DANGEROUS, because operations that do not provide it now receive the default. The change also carries a criticality.reason that explains the assigned level.

8.0.2

Patch Changes

  • #2989 a6f36e3 Thanks @jdolle! - simplifyChanges no longer hides changes to a node when a description, interface, union member, directive location or directive argument was added to that same node in the diff. The rule treated those additions like the addition of a whole node, so every later change at the same path or directly below it was dropped. The following changes were hidden before and are reported again:

    • On a field whose description was added: FIELD_TYPE_CHANGED, FIELD_ARGUMENT_ADDED, FIELD_ARGUMENT_REMOVED, FIELD_ARGUMENT_TYPE_CHANGED, FIELD_DEPRECATION_ADDED and DIRECTIVE_USAGE_FIELD_DEFINITION_ADDED.
    • On an input field whose description was added: INPUT_FIELD_TYPE_CHANGED, INPUT_FIELD_DEFAULT_VALUE_CHANGED and DIRECTIVE_USAGE_INPUT_FIELD_DEFINITION_ADDED.
    • On a type that gained an interface: FIELD_ADDED, FIELD_REMOVED and FIELD_TYPE_CHANGED on that type, DIRECTIVE_USAGE_OBJECT_ADDED, and every OBJECT_TYPE_INTERFACE_ADDED after the first.
    • On a union that gained a member: every UNION_MEMBER_ADDED after the first, and DIRECTIVE_USAGE_UNION_MEMBER_ADDED.
    • On a directive that gained a location: DIRECTIVE_LOCATION_REMOVED, every DIRECTIVE_LOCATION_ADDED after the first, DIRECTIVE_ARGUMENT_ADDED, DIRECTIVE_ARGUMENT_REMOVED, DIRECTIVE_ARGUMENT_TYPE_CHANGED and DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED.
    • On a directive that gained an argument: every DIRECTIVE_ARGUMENT_ADDED after the first, and DIRECTIVE_ARGUMENT_TYPE_CHANGED, DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED and DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED on its other arguments.

8.0.1

Patch Changes

  • #2982 1912c6b Thanks @cpruijsen! - Fix validate failing when a ... sequence occurs inside a string literal in a query or fragment. Fragment references are now collected from the parsed AST instead of a regular expression over the printed document.

8.0.0

Major Changes

  • #2965 f640d71 Thanks @n1ru4l! - Add support for graphql-js@17.

    BREAKING Drop support for Node.js 20

    BREAKING Drop support for GraphQL 14 and 15

7.1.3

Patch Changes

  • #2952 3b341d4 Thanks @jdolle! - “INPUT_FIELD_ADDED” is now classified as Dangerous (was NonBreaking) when the added field has a default value, since rolling deploys can expose consumers to the default before producers are ready.

7.1.2

Patch Changes

  • #2934 14b4410 Thanks @jdolle! - Add support for “extend schema” syntax to @graphql-inspector/core’s diff function and @graphql/inspector/patch. This allows directives to be defined on the schema such as extend schema @link(...) for federation

7.1.1

Patch Changes

  • #2930 4a37c05 Thanks @jdolle! - Add directive definition changes first; adjust adding repeat directive change

7.1.0

Minor Changes

  • #2923 9bfc094 Thanks @jdolle! - Adjust SCHEMA_*_TYPE_CHANGED changes to use null instead of ‘unknown’ when these types are not defined and improve the change messages.

  • #2923 9bfc094 Thanks @jdolle! - diff can be passed null schemas. This lets it output the full list of additions on the new schema.

7.0.4

Patch Changes

  • #2924 74fcea7 Thanks @adambenhassen! - Escape single quotes in diff change messages for descriptions and deprecation reasons

    Improve description change messages to show “was added” or “was removed” instead of “changed from ‘undefined’ to X”

7.0.3

Patch Changes

  • #2921 088cd4f Thanks @jdolle! - Fix simplifyChanges for sibling changes. E.g. if User.foo and User.bar were added, then the later would be filtered out when it shouldn’t be filtered.

7.0.2

Patch Changes

  • #2919 511afb5 Thanks @jdolle! - export directiveRepeatableAddedFromMeta and directiveRepeatableRemovedFromMeta

7.0.1

Patch Changes

  • #2916 91b8450 Thanks @jdolle! - export DirectiveRepeatableAddedChange and DirectiveRepeatableRemovedChange

7.0.0

Major Changes

  • #2893 ef13125 Thanks @jdolle! - This is a major change to @graphql-inspector/core and introduces a new @graphql-inspector/patch package, which applies changes output from diff on top of a schema — essentially rebasing these changes onto any schema.

    These changes include:

    • Numerous adjustments to Change types to create more accurate severity levels, such as a boolean indicating if the change applies to a new type or an existing type.
    • Adjustmented the “path” on several change types in order to consistently map to the exact AST node being changed. For example, EnumValueDeprecationReasonAdded’s path previously referenced the enumValue (e.g. EnumName.value), not the deprecated directive (e.g. EnumName.value.@deprecated).
    • Added new attributes in order to provide enough context for a new “@graphql-inspector/patch” function to apply changes accurately.
    • Added support for repeatable directives
    • Includes all nested changes in diff output when a new node is added. This can dramatically increase the number of changes listed which can be noisy, but it makes it possible for “@graphql-inspector/patch” to apply all changes from a schema. This can be optionally filtered using a newly exported DiffRule.simplifyChanges rule.

    For example, given an existing schema:

    type User {
      id: ID!
      name: String!
    }

    And a diff schema:

    type User {
      id: ID!
      name: String!
      address: Address
    }
    
    type Address {
      line1: String!
      line2: String!
    }

    Then previously the output would be:

    [
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Type 'Address' was added",
        "meta": {
          "addedTypeKind": "ObjectTypeDefinition",
          "addedTypeName": "Address"
        },
        "path": "Address",
        "type": "TYPE_ADDED"
      },
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Field 'address' was added to object type 'User'",
        "meta": {
          "addedFieldName": "address",
          "addedFieldReturnType": "Address",
          "typeName": "User",
          "typeType": "object type"
        },
        "path": "User.address",
        "type": "FIELD_ADDED"
      }
    ]

    But now the output also includes the fields inside the new Address type:

    [
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Type 'Address' was added",
        "meta": {
          "addedTypeKind": "ObjectTypeDefinition",
          "addedTypeName": "Address"
        },
        "path": "Address",
        "type": "TYPE_ADDED"
      },
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Field 'line1' was added to object type 'Address'",
        "meta": {
          "addedFieldName": "line1",
          "addedFieldReturnType": "String!",
          "typeName": "Address",
          "typeType": "object type"
        },
        "path": "Address.line1",
        "type": "FIELD_ADDED"
      },
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Field 'line2' was added to object type 'Address'",
        "meta": {
          "addedFieldName": "line2",
          "addedFieldReturnType": "String!",
          "typeName": "Address",
          "typeType": "object type"
        },
        "path": "Address.line2",
        "type": "FIELD_ADDED"
      },
      {
        "criticality": {
          "level": "NON_BREAKING"
        },
        "message": "Field 'address' was added to object type 'User'",
        "meta": {
          "addedFieldName": "address",
          "addedFieldReturnType": "Address",
          "typeName": "User",
          "typeType": "object type"
        },
        "path": "User.address",
        "type": "FIELD_ADDED"
      }
    ]

    These additional changes can be filtered using a new rule:

    import { diff, DiffRule } from '@graphql-inspector/core'
    
    const changes = await diff(a, b, [DiffRule.simplifyChanges])

Minor Changes

  • #2900 2fc8b25 Thanks @emileriksson! - Apollo Federation v2 support. Introduced built-in Federation v2 directives and a new CLI flag —federationV2 to enable processing schemas that use them.

6.4.1

Patch Changes

6.4.0

Minor Changes

6.3.0

Minor Changes

  • #2906 2d22d32 Thanks @adambenhassen! - add missing change detection of directive field usage and exports ‘directiveUsageFieldAddedFromMeta’ & ‘directiveUsageFieldRemovedFromMeta’

  • #2838 416a9ce Thanks @egoodwinx! - Updated removing field message to contain more information on why its a breaking change such as if the field is a union or indirectly referenced.

6.2.1

Patch Changes

6.2.0

Minor Changes

  • #2827 60d674d Thanks @TuvalSimha! - Added missing types to Change type and fix typo “DirectiveUsageInputObjectdRemovedChange” to “DirectiveUsageInputObjectRemovedChange”

6.1.0

Minor Changes

Patch Changes

6.0.1

Patch Changes

6.0.0

Major Changes

  • #2719 50874f2 Thanks @TuvalSimha! - Upgrade the Node version from 16 to 18, as the minimum required version is now 18. Additionally, ensure that GraphQL Yoga is upgraded to version 5.

5.1.0

Minor Changes

5.0.2

Patch Changes

5.0.1

Patch Changes

5.0.0

Major Changes

Patch Changes

4.2.2

Patch Changes

  • #2452 1b1b954c Thanks @TuvalSimha! - Add a new stats display for coverage command + display new Total queries / mutations / Sub

4.2.1

Patch Changes

4.2.0

Minor Changes

4.1.1

Patch Changes

4.1.0

Minor Changes

  • #2392 3184249b Thanks @n1ru4l! - Wrap string values in quotes, so they can be differentiated from types.

    - Input field 'Foo.b' default value changed from 'undefined' to 'Bbb'
    + Input field 'Foo.b' default value changed from 'undefined' to '"Bbb"'
  • #2392 3184249b Thanks @n1ru4l! - Add isSafeBasedOnUsage to Criticality type. This value is set to true in case the criticality is set to CriticalityLevel.Dangerous based on usage. This is helpful for statistics.

  • #2392 3184249b Thanks @n1ru4l! - include meta data in the changes that are machine processable. This is useful if you want to efficiently store the changes in some database and later-on reconstruct the full change objects.

    export type FieldDescriptionChangedChange = {
      type: ChangeType.FieldDescriptionChanged
      meta: {
        typeName: string
        fieldName: string
        oldDescription: string
        newDescription: string
      }
    }

    You can construct the full Change object from the type and meta properties.

    import { ChangeType, fieldDescriptionChangedFromMeta } from '@graphql-inspector/core'
    
    console.log(
      fieldDescriptionChangedFromMeta({
        type: ChangeType.FieldDescriptionChanged,
        meta: {
          typeName: 'Foo',
          fieldName: 'bar',
          oldDescription: 'This is the old description',
          newDescription: 'This is the new description'
        }
      })
    )

    console.log output:

    {
      type: 'FIELD_DESCRIPTION_CHANGED',
      criticality: { level: 'NON_BREAKING' },
      message: "Field 'Foo.bar' description changed from 'This is the old description' to 'This is the new description'",
      meta: {
        typeName: 'Foo',
        fieldName: 'bar',
        oldDescription: 'This is the old description',
        newDescription: 'This is the new description'
      },
      path: 'Foo.bar'
    }

4.0.3

Patch Changes

  • #2419 34f84e8f Thanks @TuvalSimha! - Update bob version -> change the way we build the packages (Dist folder build now esm and cjs versions)

4.0.2

Patch Changes

4.0.1

Patch Changes

4.0.0

Major Changes

3.5.1

Patch Changes

3.5.0

Minor Changes

  • #2240 ca29cdd1 Thanks @Tohaker! - suppressRemovalOfDeprecatedField rule will now mark removed types as dangerous