Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/code-file-loader

Package Overview
Dependencies
Maintainers
3
Versions
1113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/code-file-loader

A set of utils for faster development of GraphQL tools

  • 5.0.1-alpha-422d6a6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8M
decreased by-17.5%
Maintainers
3
Weekly downloads
 
Created

What is @graphql-tools/code-file-loader?

The @graphql-tools/code-file-loader package is part of the GraphQL Tools ecosystem and is designed to load and parse GraphQL schema definitions and documents from various file types. It supports loading from .graphql, .graphqls, .gql, .js, and .ts files. This loader is particularly useful in building GraphQL schemas directly from files, making it easier to manage and modularize GraphQL codebases.

What are @graphql-tools/code-file-loader's main functionalities?

Load GraphQL schema from code files

This feature allows developers to load GraphQL schemas directly from .graphql, .js, or .ts files. The code sample demonstrates how to use the codeFileLoader with the loadSchema function from @graphql-tools/load to asynchronously load a schema from a .graphql file.

import { loadSchema } from '@graphql-tools/load';
import { codeFileLoader } from '@graphql-tools/code-file-loader';

async function getSchema() {
  const schema = await loadSchema('./schema.graphql', {
    loaders: [codeFileLoader]
  });
  return schema;
}

Merge resolvers and type definitions

This feature supports loading and merging both resolvers and type definitions from multiple files. The code sample shows how to use loadFiles to load all resolver and type definition files from a project, and then use makeExecutableSchema to combine them into a single executable schema.

import { loadFiles } from '@graphql-tools/load-files';
import { makeExecutableSchema } from '@graphql-tools/schema';

async function buildSchema() {
  const typesArray = await loadFiles('**/*.typeDefs.{js,ts}');
  const resolversArray = await loadFiles('**/*.resolvers.{js,ts}');
  const schema = makeExecutableSchema({
    typeDefs: typesArray,
    resolvers: resolversArray
  });
  return schema;
}

Other packages similar to @graphql-tools/code-file-loader

FAQs

Package last updated on 28 Apr 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc