Socket
Socket
Sign inDemoInstall

@graphql-tools/load

Package Overview
Dependencies
5
Maintainers
3
Versions
1163
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/load

A set of utils for faster development of GraphQL tools


Version published
Weekly downloads
3.8M
increased by14.15%
Maintainers
3
Install size
646 kB
Created
Weekly downloads
 

Package description

What is @graphql-tools/load?

@graphql-tools/load is a part of the GraphQL Tools ecosystem that allows you to load GraphQL schema and documents from various sources. It supports loading from files, URLs, and even code strings, making it versatile for different use cases in GraphQL development.

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

Load schema from a file

This feature allows you to load a GraphQL schema from a file. The code sample demonstrates how to use the `loadSchema` function along with the `GraphQLFileLoader` to load a schema from a specified file path.

const { loadSchema } = require('@graphql-tools/load');
const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader');

async function loadSchemaFromFile() {
  const schema = await loadSchema('path/to/schema.graphql', {
    loaders: [new GraphQLFileLoader()]
  });
  console.log(schema);
}

loadSchemaFromFile();

Load schema from a URL

This feature allows you to load a GraphQL schema from a URL. The code sample demonstrates how to use the `loadSchema` function along with the `UrlLoader` to load a schema from a specified URL.

const { loadSchema } = require('@graphql-tools/load');
const { UrlLoader } = require('@graphql-tools/url-loader');

async function loadSchemaFromURL() {
  const schema = await loadSchema('https://example.com/graphql', {
    loaders: [new UrlLoader()]
  });
  console.log(schema);
}

loadSchemaFromURL();

Load schema from a code string

This feature allows you to load a GraphQL schema from a code string. The code sample demonstrates how to use the `loadSchema` function to load a schema directly from a string containing the schema definition.

const { loadSchema } = require('@graphql-tools/load');
const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader');

const schemaString = `
  type Query {
    hello: String
  }
`;

async function loadSchemaFromString() {
  const schema = await loadSchema(schemaString, {
    loaders: [new GraphQLFileLoader()]
  });
  console.log(schema);
}

loadSchemaFromString();

Other packages similar to @graphql-tools/load

Readme

Source

Check API Reference for more information about this package; https://www.graphql-tools.com/docs/api/modules/load_src

You can also learn more about Apollo Links in Schema Loading in this chapter; https://www.graphql-tools.com/docs/schema-loading

You can also learn more about Apollo Links in Documents Loading in this chapter; https://www.graphql-tools.com/docs/documents-loading

FAQs

Last updated on 27 Oct 2021

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc