What is @graphql-inspector/loaders?
@graphql-inspector/loaders is a package that provides various loaders for GraphQL schemas and documents. It allows you to load GraphQL schemas from different sources such as files, URLs, and more, making it easier to work with GraphQL in different environments.
What are @graphql-inspector/loaders's main functionalities?
Load Schema from File
This feature allows you to load a GraphQL schema from a local file. The `loadSchema` function takes the file path as an argument and returns the schema.
const { loadSchema } = require('@graphql-inspector/loaders');
const schema = loadSchema('path/to/schema.graphql');
console.log(schema);
Load Schema from URL
This feature allows you to load a GraphQL schema from a URL. The `loadSchema` function takes the URL as an argument and returns the schema.
const { loadSchema } = require('@graphql-inspector/loaders');
const schema = loadSchema('https://example.com/schema.graphql');
console.log(schema);
Load Documents from File
This feature allows you to load GraphQL documents from a local file. The `loadDocuments` function takes the file path as an argument and returns the documents.
const { loadDocuments } = require('@graphql-inspector/loaders');
const documents = loadDocuments('path/to/documents.graphql');
console.log(documents);
Load Documents from URL
This feature allows you to load GraphQL documents from a URL. The `loadDocuments` function takes the URL as an argument and returns the documents.
const { loadDocuments } = require('@graphql-inspector/loaders');
const documents = loadDocuments('https://example.com/documents.graphql');
console.log(documents);
Other packages similar to @graphql-inspector/loaders
graphql-tools
graphql-tools is a package that provides a set of utilities to work with GraphQL schemas and resolvers. It includes schema stitching, schema transforms, and more. Compared to @graphql-inspector/loaders, graphql-tools offers a broader range of utilities beyond just loading schemas and documents.
graphql-import
graphql-import is a package that allows you to import .graphql files into your JavaScript or TypeScript code. It provides a simple way to modularize your GraphQL schema. While @graphql-inspector/loaders focuses on loading schemas and documents from various sources, graphql-import is specifically designed for importing .graphql files.
graphql-tag
graphql-tag is a package that parses GraphQL queries into the standard GraphQL AST. It is commonly used with Apollo Client and other GraphQL clients. Unlike @graphql-inspector/loaders, which focuses on loading schemas and documents, graphql-tag is used for parsing GraphQL queries.