-
-
Notifications
You must be signed in to change notification settings - Fork 826
support import path mappings #7311
Description
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:
- Use long relative paths that break when files are moved or are inconvenient in monorepo / deeply nested projects
- Write custom preprocessors using
extractImportLinesto rewrite imports - Avoid modular GraphQL schema design altogether
These workarounds require additional build steps and tooling complexity that shouldn't be necessary.