Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@graphql-tools/load-files
Advanced tools
A set of utils for faster development of GraphQL tools
@graphql-tools/load-files is a utility package that allows you to load files from the file system, specifically for GraphQL schema and resolvers. It is part of the GraphQL Tools ecosystem and is designed to help you modularize your GraphQL code by loading multiple files and merging them into a single schema or resolver map.
Load GraphQL Type Definitions
This feature allows you to load GraphQL type definitions from .graphql files. The `loadFilesSync` function synchronously loads all files matching the given pattern and returns an array of type definitions.
const { loadFilesSync } = require('@graphql-tools/load-files');
const typeDefs = loadFilesSync('**/*.graphql');
console.log(typeDefs);
Load Resolvers
This feature allows you to load resolver functions from JavaScript or TypeScript files. The `loadFilesSync` function synchronously loads all files matching the given pattern and returns an array of resolver objects.
const { loadFilesSync } = require('@graphql-tools/load-files');
const resolvers = loadFilesSync('**/*.{js,ts}');
console.log(resolvers);
Load Files Asynchronously
This feature allows you to load files asynchronously. The `loadFiles` function returns a promise that resolves to an array of loaded files, which can be useful for non-blocking operations.
const { loadFiles } = require('@graphql-tools/load-files');
(async () => {
const typeDefs = await loadFiles('**/*.graphql');
console.log(typeDefs);
})();
graphql-import allows you to import .graphql files into your JavaScript or TypeScript code. It is similar to @graphql-tools/load-files in that it helps modularize your GraphQL schema, but it focuses specifically on importing and merging .graphql files.
merge-graphql-schemas is a utility to merge multiple GraphQL schemas and resolver maps into a single schema. It provides similar functionality to @graphql-tools/load-files but is more focused on the merging aspect rather than file loading.
graphql-tag is a library that parses GraphQL schema language into the GraphQL AST. While it doesn't load files from the filesystem, it is often used in conjunction with file loading utilities to parse the loaded schema strings into AST nodes.
Check API Reference for more information about this package; https://www.graphql-tools.com/docs/api/modules/load-files
You can also learn more about File Loading in this chapter; https://www.graphql-tools.com/docs/schema-merging#file-loading
FAQs
A set of utils for faster development of GraphQL tools
The npm package @graphql-tools/load-files receives a total of 308,050 weekly downloads. As such, @graphql-tools/load-files popularity was classified as popular.
We found that @graphql-tools/load-files demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.