Skip to Content
GraphQL Tools

@graphql-tools/import

7.2.0

Minor Changes

  • #8383 04e8159 Thanks @ardatan! - # import paths may use a require: prefix, resolved with Node’s require.resolve from the importing file. Example: # import Post from "require:blog-graphql-types/schema.graphql" or # import A from "require:./a.graphql".

Patch Changes

  • #8383 04e8159 Thanks @ardatan! - # import "./file.graphql" (space after #) is a valid default import, and #import is processed even when it is not the first non-blank line of the file.

  • #8383 04e8159 Thanks @ardatan! - Keep leading GraphQL comments (for example # eslint-disable-next-line above a query) when #import merges documents. Previously processImport reprinted definitions and dropped those comments from the merged source.

  • #8383 04e8159 Thanks @ardatan! - # import * keeps unreferenced types that carry a federation @key (subgraph entities). Other unused types are still tree-shaken, matching existing import * tests.

  • #8383 04e8159 Thanks @ardatan! - Named # import of a type no longer drops interfaces implemented by union members.

    Before this, a file like:

    # import Foo from "./types.graphql" type Query { foo: Foo }

    with types.graphql containing type Foo { pet: Pet }, union Pet = Cat | Dog, and type Cat implements Animal built an invalid schema (Unknown type "Animal"). Cat and Dog were pulled in through the union, but Animal was not.

    Forward dependencies (fields, implements, union members) are now closed transitively. Reverse implementers are still attached only when the interface itself is the import, so # import Query.posts does not pull every other Query field.

  • Updated dependencies [60db079, 57e316d, 1c1c5a0, 1c1c5a0, 0b9529f]:

    • @graphql-tools/utils@12.0.1

7.1.19

Patch Changes

  • #8259 85f1de0 Thanks @lemonmade! - perf(import): remove redundant work in addDefinition’s dependency traversal

    addDefinition recurses across the whole dependency graph while assembling each definition’s imported dependencies. Two things were repeated on every call:

    • visitedFiles.get(filePath) — invariant for the duration of the processImport call, so it’s now looked up once and hoisted out of the recursion.
    • the per-field dependency-name derivation (visitFieldDefinitionNode / visitInputValueDefinitionNode into a fresh Map) — a pure function of the field node and the file’s static dependency map, so it’s now memoized by field identity instead of recomputed every time the owning definition is added to a set.

    Pure performance change; output is unchanged (the existing import tests pass and a real-world ~12k-line schema produces byte-identical results). Building on the print memoization, this took the same codegen pass from ~17s to ~13s. The remaining cost is the O(n²) shape of the closure traversal itself (each definition’s transitive set is still rebuilt independently); reducing that is left for a follow-up as it’s a more invasive change.

  • #8258 6bacf57 Thanks @lemonmade! - perf(import): memoize print per node when assembling imported definitions

    processImport de-duplicates the collected definitions by printing each one to SDL and comparing the strings. A single definition node appears in many of the dependency sets (any widely-referenced type is pulled in by every definition that depends on it), so print was called roughly O(n²) times for n unique nodes. For large, densely-connected schemas this print/visit work dominates import time.

    Memoizing print by node identity makes each unique node print at most once. print is a pure function of its node, so the output is identical; this is a pure performance change. On a ~12k-line schema imported across three projects, this reduced a downstream codegen pass from ~133s to ~17s.

  • Updated dependencies [2273c21]:

    • @graphql-tools/utils@12.0.0

7.1.18

Patch Changes

  • Updated dependencies [e90719b]:
    • @graphql-tools/utils@11.2.2

7.1.17

Patch Changes

  • Updated dependencies [615c1a2]:
    • @graphql-tools/utils@11.2.1

7.1.16

Patch Changes

  • Updated dependencies [2609c94]:
    • @graphql-tools/utils@11.2.0

7.1.15

Patch Changes

  • Updated dependencies [981d461]:
    • @graphql-tools/utils@11.1.1

7.1.14

Patch Changes

  • Updated dependencies [a4b7dce]:
    • @graphql-tools/utils@11.1.0

7.1.13

Patch Changes

  • Updated dependencies [ae36a0e]:
    • @graphql-tools/utils@11.0.1

7.1.12

Patch Changes

7.1.11

Patch Changes

7.1.10

Patch Changes

7.1.9

Patch Changes

7.1.8

Patch Changes

7.1.7

Patch Changes

7.1.6

Patch Changes

  • Updated dependencies [2fe123a]:
    • @graphql-tools/utils@10.10.3

7.1.5

Patch Changes

  • Updated dependencies [dddc5f6]:
    • @graphql-tools/utils@10.10.2

7.1.4

Patch Changes

  • Updated dependencies [fbb58b5]:
    • @graphql-tools/utils@10.10.1

7.1.3

Patch Changes

7.1.2

Patch Changes

7.1.1

Patch Changes

  • #7433 07124d5 Thanks @HunterLarco! - Fix support for absolute path aliases in GraphQL imports

    Path aliases configured with absolute paths (e.g., /*src/*) now work correctly alongside relative aliases (e.g., @/*src/*). This allows more flexible aliasing configurations when using tsconfig.json#paths syntax for GraphQL imports.

  • #7437 211ef44 Thanks @HunterLarco! - enhance GraphQL schema import error debugging with source locations

7.1.0

Minor Changes

  • #7310 692cfeb Thanks @HunterLarco! - GraphQL schemas in large projects, especially monorepos, suffer from fragile and verbose relative import paths that become difficult to maintain as projects grow. This change brings TypeScript’s popular tsconfig.json#paths aliasing syntax to GraphQL imports, enabling clean, maintainable import statements across your GraphQL schema files.

    Before - Brittle relative imports:

    #import "../../../shared/models/User.graphql" #import "../../../../common/types/Product.graphql"

    After - Clean, semantic aliases:

    #import "@models/User.graphql" #import "@types/Product.graphql"

    Configuration Example

    { mappings: { '@models/*': path.join(__dirname, './models/*'), '@types/*': path.join(__dirname, './shared/types/*'), } }

    This change is introduced in a backwards compatible way to ensure no existing use cases are broken while using familiar patterns to typescript developers for structuring import aliases.

7.0.21

Patch Changes

  • Updated dependencies [32d0457]:
    • @graphql-tools/utils@10.9.1

7.0.20

Patch Changes

7.0.19

Patch Changes

  • #7225 99e6faf Thanks @jdolle! - Support ‘extend schema’ syntax and add ‘link’ to the list of builtins so that it doesnt need a directive definition for federated schemas

7.0.18

Patch Changes

  • Updated dependencies [d123e26]:
    • @graphql-tools/utils@10.8.6

7.0.17

Patch Changes

  • Updated dependencies [90a717e, 26518de]:
    • @graphql-tools/utils@10.8.5

7.0.16

Patch Changes

  • Updated dependencies [155944b]:
    • @graphql-tools/utils@10.8.4

7.0.15

Patch Changes

  • Updated dependencies [4a2eb14]:
    • @graphql-tools/utils@10.8.3

7.0.14

Patch Changes

  • Updated dependencies [3547bba]:
    • @graphql-tools/utils@10.8.2

7.0.13

Patch Changes

  • Updated dependencies [651a5dc]:
    • @graphql-tools/utils@10.8.1

7.0.12

Patch Changes

  • Updated dependencies [0a3e193, 357b2ee]:
    • @graphql-tools/utils@10.8.0

7.0.11

Patch Changes

  • Updated dependencies [53bb601, 53bb601]:
    • @graphql-tools/utils@10.7.2

7.0.10

Patch Changes

  • Updated dependencies [4912f19]:
    • @graphql-tools/utils@10.7.1

7.0.9

Patch Changes

  • #6796 ddfef2c Thanks @ardatan! - Avoid importing process and use it from globalThis. In some cases, cwd is not exported with this name in the environment in ESM scope.
  • Updated dependencies [2c70d27]:
    • @graphql-tools/utils@10.7.0

7.0.8

Patch Changes

  • Updated dependencies [6a8123b]:
    • @graphql-tools/utils@10.6.4

7.0.7

Patch Changes

  • Updated dependencies [020b9e4]:
    • @graphql-tools/utils@10.6.3

7.0.6

Patch Changes

7.0.5

Patch Changes

  • Updated dependencies [1e02935]:
    • @graphql-tools/utils@10.6.1

7.0.4

Patch Changes

  • Updated dependencies [414e404]:
    • @graphql-tools/utils@10.6.0

7.0.3

Patch Changes

  • Updated dependencies [dc5043b]:
    • @graphql-tools/utils@10.5.6

7.0.2

Patch Changes

  • Updated dependencies [cf2ce5e]:
    • @graphql-tools/utils@10.5.5

7.0.1

Patch Changes

7.0.0

Major Changes

Patch Changes

6.7.18

Patch Changes

6.7.17

Patch Changes

  • Updated dependencies [b5c8f640]:
    • @graphql-tools/utils@9.2.1

6.7.16

Patch Changes

6.7.15

Patch Changes

  • Updated dependencies [e3ec35ed]:
    • @graphql-tools/utils@9.1.4

6.7.14

Patch Changes

  • Updated dependencies [904fe770]:
    • @graphql-tools/utils@9.1.3

6.7.13

Patch Changes

  • Updated dependencies [13c24883]:
    • @graphql-tools/utils@9.1.2

6.7.12

Patch Changes

  • Updated dependencies [7411a5e7]:
    • @graphql-tools/utils@9.1.1

6.7.11

Patch Changes

  • Updated dependencies [c0639dd0]:
    • @graphql-tools/utils@9.1.0

6.7.10

Patch Changes

  • Updated dependencies [d83b1960]:
    • @graphql-tools/utils@9.0.1

6.7.9

Patch Changes

6.7.8

Patch Changes

  • Updated dependencies [f7daf777]:
    • @graphql-tools/utils@8.13.1

6.7.7

Patch Changes

6.7.6

Patch Changes

  • Updated dependencies [43c736bd]:
    • @graphql-tools/utils@8.12.0

6.7.5

Patch Changes

6.7.4

Patch Changes

  • Updated dependencies [4fe3d9c0]:
    • @graphql-tools/utils@8.10.1

6.7.3

Patch Changes

  • Updated dependencies [2609d71f]:
    • @graphql-tools/utils@8.10.0

6.7.2

Patch Changes

  • #4624 e3167edc Thanks @n1ru4l! - Fix CommonJS TypeScript resolution with moduleResolution node16 or nodenext

  • Updated dependencies [e3167edc]:

    • @graphql-tools/utils@8.9.1

6.7.1

Patch Changes

  • Updated dependencies [2a3b45e3]
    • @graphql-tools/utils@8.9.0

6.7.0

Minor Changes

  • d76a299c: Support TypeScript module resolution.

Patch Changes

  • Updated dependencies [a0abbbcd]
  • Updated dependencies [d76a299c]
    • @graphql-tools/utils@8.8.0

6.6.18

Patch Changes

  • Updated dependencies [4914970b]
    • @graphql-tools/utils@8.7.0

6.6.17

Patch Changes

  • 041c5ba1: Use caret range for the tslib dependency
  • Updated dependencies [041c5ba1]
    • @graphql-tools/utils@8.6.13

6.6.16

Patch Changes

  • a5386350: fix(import): import dependent interfaces correctly
  • Updated dependencies [da7ad43b]
    • @graphql-tools/utils@8.6.12

6.6.15

Patch Changes

  • Updated dependencies [c0762ee3]
    • @graphql-tools/utils@8.6.11

6.6.14

Patch Changes

  • Updated dependencies [0fc510cb]
    • @graphql-tools/utils@8.6.10

6.6.13

Patch Changes

  • Updated dependencies [31a33e2b]
    • @graphql-tools/utils@8.6.9

6.6.12

Patch Changes

  • Updated dependencies [cb238877]
    • @graphql-tools/utils@8.6.8

6.6.11

Patch Changes

  • Updated dependencies [0bbb1769]
    • @graphql-tools/utils@8.6.7

6.6.10

Patch Changes

  • Updated dependencies [904c0847]
    • @graphql-tools/utils@8.6.6

6.6.9

Patch Changes

  • Updated dependencies [be2c02d7]
    • @graphql-tools/utils@8.6.5

6.6.8

Patch Changes

  • Updated dependencies [d36d530b]
    • @graphql-tools/utils@8.6.4

6.6.7

Patch Changes

  • Updated dependencies [3da3d66c]
    • @graphql-tools/utils@8.6.3

6.6.6

Patch Changes

  • Updated dependencies [18341363]
    • @graphql-tools/utils@8.6.2

6.6.5

Patch Changes

  • Updated dependencies [43a60f93]
  • Updated dependencies [20e1058b]
    • @graphql-tools/utils@8.6.1

6.6.4

Patch Changes

  • 7c6b28e6: Changes to the documentation regarding processImport
  • Updated dependencies [69b316c2]
    • @graphql-tools/utils@8.6.0

6.6.3

Patch Changes

  • Updated dependencies [7b5d72c5]
    • @graphql-tools/utils@8.5.5

6.6.2

Patch Changes

  • Updated dependencies [51315610]
    • @graphql-tools/utils@8.5.4

6.6.1

Patch Changes

  • Updated dependencies [960e178a]
  • Updated dependencies [947a3fe0]
    • @graphql-tools/utils@8.5.3

6.6.0

Minor Changes

  • 61e00a6d: fix(import): allow import nested fragments

6.5.8

Patch Changes

  • Updated dependencies [233e0379]
    • @graphql-tools/utils@8.5.2

6.5.7

Patch Changes

  • 4bfb3428: enhance: use ^ for tslib dependency
  • Updated dependencies [4bfb3428]
    • @graphql-tools/utils@8.5.1

6.5.6

Patch Changes

  • Updated dependencies [ad04dc79]
    • @graphql-tools/utils@8.5.0

6.5.5

Patch Changes

  • Updated dependencies [149afddb]
    • @graphql-tools/utils@8.4.0

6.5.4

Patch Changes

  • Updated dependencies [58262be7]
    • @graphql-tools/utils@8.3.0

6.5.3

Patch Changes

  • 8ffbb600: Remove code causing Maximum call stack size exceeded in @graphql-tools/import package.

6.5.2

Patch Changes

  • Updated dependencies [1043219f]
    • @graphql-tools/utils@8.2.5

6.5.1

Patch Changes

  • be9fad09: fix(import): add missing dependency

6.5.0

Minor Changes

  • 1e90f094: Refactor processImport and export helper functions for parsing GraphQL imports

6.4.2

Patch Changes

  • a78fd76c: Schemata containing only imports will now resolve imported type’s transitive dependencies.

6.4.1

Patch Changes

  • 652c21d7: #3327 - Transitive schema definition dependencies are now included in building out the full dependency structure.

6.4.0

Minor Changes

  • c5b0719c: feat: GraphQL v16 support

6.3.1

Patch Changes

  • 77902864: fix(import): handle nested imports correctly

6.3.0

Minor Changes

  • 87709f42: processImport() now lets you know all the visited files by passing a map as a fourth argument.

6.2.6

Patch Changes

  • 5ec2e354: enhance(import): handle duplicate definitions

6.2.5

Patch Changes

  • eacf0dc3: Replace fs-extra with native methods

6.2.4

Patch Changes

  • 32c3c4f8: feat(import): support specifiedBy builtin directive
  • 533d6d53: Bump all packages to allow adjustments