
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
graphql-import-files
Advanced tools
Light and easy package that will load .graphql files and use them with syntax highlighting.
Light and easy package that will load .graphql files and use them with syntax highlighting.
npm i -S graphql-import-files
For example, your files and folders look like this:
root
├──src
├──index.js
├──schema
├──schema.graphql
Use the function loadFile
that will load a single file.
// index.js
const { ApolloServer } = require('apollo-server')
const { loadFile } = require('graphql-import-files')
const resolvers = require('./resolvers')
const server = new ApolloServer({
typeDefs: loadFile('./schema/schema.graphql'), // Always consider the path at the root of the project
resolvers
})
server.listen().then(({ url }) => {
console.log(`Running on ${url}`)
})
The loadFile
function supports the #import
annotation and this will allow you to load other files as if it were the import in a js file.
root
├──src
├──index.js
├──schema
├──schema.graphql
├──user
├──user.graphql
├──location
├──location.graphql
./src/schema/schema.graphql
#import './user/user.graphql'
#import './location/location.graphql'
type Query {
user(id: ID!): User
location(id: ID!): Location
}
./src/schema/user/user.graphql
type User {
id: ID!
name: String!
}
./src/schema/location/location.graphql
type Location {
id: ID!
name: String!
}
// index.js
// ...
const { loadFile } = require('graphql-import-files')
const server = new ApolloServer({
typeDefs: loadFile('./schema/schema.graphql'), // Always consider the path at the root of the project
resolvers
})
// ...
For example, your files and folders look like this:
root
├──src
├──index.js
├──schemas
├──query.graphql
├──user
├──user.gql
├──role.gql
├──product
├──product.graphql
Use the function loadFiles
that will load multiple files.
// index.js
const { ApolloServer } = require('apollo-server')
const { loadFiles } = require('graphql-import-files')
const resolvers = require('./resolvers')
const server = new ApolloServer({
typeDefs: loadFiles('**/schemas/**/*.{graphql,gql}'), // Use the glob pattern to find multiple files
resolvers
})
server.listen().then(({ url }) => {
console.log(`Running on ${url}`)
})
v1.5.2 / 2024-10-06
FAQs
Light and easy package that will load .graphql files and use them with syntax highlighting.
The npm package graphql-import-files receives a total of 145 weekly downloads. As such, graphql-import-files popularity was classified as not popular.
We found that graphql-import-files demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.