Skip to content

support import path mappings #7311

@HunterLarco

Description

@HunterLarco

Is your feature request related to a problem? Please describe.

GraphQL tooling currently lacks support for import aliases/path mappings, a feature that's standard in TypeScript projects through tsconfig#paths and build tools like @rollup/plugin-alias. This forces developers to use relative imports (e.g., ../../../types/user.graphql) which are brittle and difficult to maintain, especially in monorepo setups or projects with deep directory structures.

Describe the solution you'd like

Add import alias support to @graphql-tools/import that allows mapping import paths similar to TypeScript's path mapping:

  • Exact mappings: 'base-schema': '/path/to/schema.graphql'
  • Wildcard mappings: '@types/*': '/path/to/types/*'

This enables cleaner imports like:

#import User from "@types/user"
#import BaseSchema from "base-schema"

Describe alternatives you've considered

Currently, developers must either:

  1. Use long relative paths that break when files are moved or are inconvenient in monorepo / deeply nested projects
  2. Write custom preprocessors using extractImportLines to rewrite imports
  3. Avoid modular GraphQL schema design altogether

These workarounds require additional build steps and tooling complexity that shouldn't be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions