Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
graphql-config
Advanced tools
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)
The graphql-config npm package provides a set of utilities to make it easier to configure and use GraphQL in your development environment. It allows for the centralization of GraphQL project configurations, making it simpler to share settings across different tools such as IDEs, GraphQL clients, and other utilities that work with GraphQL.
Loading GraphQL Project Configuration
This feature allows you to load the GraphQL project configuration. The `loadConfig` function asynchronously loads the configuration from the default or specified configuration file.
const { loadConfig } = require('graphql-config');
async function main() {
const config = await loadConfig();
console.log(config);
}
main();
Getting Schema Information
This feature enables you to retrieve the GraphQL schema information from the configuration. It's useful for tools and applications that need to introspect the schema.
const { loadConfig } = require('graphql-config');
async function main() {
const config = await loadConfig();
const schema = await config.getDefault().getSchema();
console.log(schema);
}
main();
Working with Endpoints
This feature allows for the management of GraphQL API endpoints within the configuration. It simplifies the process of switching between different environments or API versions.
const { loadConfig } = require('graphql-config');
async function main() {
const config = await loadConfig();
const endpoint = config.getDefault().endpoint('default');
console.log(endpoint);
}
main();
graphql-tools is a package that provides a set of utilities for building and working with GraphQL schemas. It is similar to graphql-config in that it helps with GraphQL development, but it focuses more on schema creation, mocking, and stitching, rather than configuration management.
apollo-server is a community-driven, open-source GraphQL server. It's similar to graphql-config in the sense that it's used in GraphQL development environments. However, apollo-server focuses on building and running GraphQL servers, including features like schema definition, data fetching, and request handling, rather than on project configuration.
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs).
schema: ./schema.json
documents: ./src/components/**/*.jsx
Install:
yarn add graphql-config
npm install graphql-config
Use:
Very basic outline in TypeScript:
import {loadConfig} from 'graphql-config';
async function main() {
const config = await loadConfig({...});
const schema = await config.getDefault().getSchema();
}
The ...
expression in the loadConfig
function is a placeholder for a LoadConfigOptions
object; leaving this space empty will pass defaults.
Here is a more robust, working example using a generate
extension from the GraphQL CLI Backend Template:
const config = await loadConfig({
extensions: [() => ({ name: 'generate'})]
});
const generateConfig = await config!.getDefault().extension('generate');
...
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
Join our Discord chat if you run into issues or have questions. We love talking to you!
FAQs
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)
The npm package graphql-config receives a total of 2,067,964 weekly downloads. As such, graphql-config popularity was classified as popular.
We found that graphql-config 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.