New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/import

Package Overview
Dependencies
Maintainers
4
Versions
923
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/import

A set of utils for faster development of GraphQL tools

7.0.12-alpha-20250130082022-c90a3fa21ee12802ea4003345c91f95324684bf2
Source
npm
Version published
Weekly downloads
3.9M
-1.3%
Maintainers
4
Weekly downloads
 
Created

What is @graphql-tools/import?

@graphql-tools/import is a utility package that allows you to import and merge GraphQL type definitions from multiple files. This is particularly useful for organizing your GraphQL schema into smaller, more manageable pieces.

What are @graphql-tools/import's main functionalities?

Importing Type Definitions

This feature allows you to import and merge GraphQL type definitions from multiple files. The `loadFilesSync` function loads all the type definition files from the specified directory, and `mergeTypeDefs` merges them into a single schema.

const { loadFilesSync } = require('@graphql-tools/load-files');
const { mergeTypeDefs } = require('@graphql-tools/merge');

const typesArray = loadFilesSync(path.join(__dirname, './schemas'));
const typeDefs = mergeTypeDefs(typesArray);

console.log(typeDefs);

Using SDL Imports

This feature allows you to use SDL (Schema Definition Language) imports within your GraphQL schema files. The `importSchema` function reads a schema file and resolves any `#import` statements, merging the imported types into a single schema.

const { importSchema } = require('@graphql-tools/import');

const typeDefs = importSchema('./path/to/schema.graphql');

console.log(typeDefs);

Other packages similar to @graphql-tools/import

FAQs

Package last updated on 30 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts