Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@graphql-tools/load
Advanced tools
A set of utils for faster development of GraphQL tools
@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.
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();
graphql-import allows you to import .graphql files into your JavaScript or TypeScript code. It is similar to @graphql-tools/load in that it helps in loading GraphQL schemas, but it is more focused on importing and merging schema files.
apollo-server is a fully-featured GraphQL server that also includes utilities for loading schemas from various sources. While it provides more than just schema loading, its schema loading capabilities are comparable to those of @graphql-tools/load.
graphql-tools is a comprehensive set of utilities for building and maintaining GraphQL schemas. It includes schema loading capabilities similar to @graphql-tools/load, but also offers additional features like schema stitching and mocking.
FAQs
A set of utils for faster development of GraphQL tools
The npm package @graphql-tools/load receives a total of 2,996,734 weekly downloads. As such, @graphql-tools/load popularity was classified as popular.
We found that @graphql-tools/load demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.