
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@fabien0102/graphql-import
Advanced tools
[](https://circleci.com/gh/prismagraphql/graphql-import) [](https://badge.fury.io/js/graphql-import)
Import & export definitions in GraphQL SDL (also refered to as GraphQL modules)
There is also a
graphql-import-loader
for Webpack available.
yarn add graphql-import
import { importSchema } from 'graphql-import'
import { makeExecutableSchema } from 'graphql-tools'
const typeDefs = importSchema('schema.graphql')
const resolvers = {}
const schema = makeExecutableSchema({ typeDefs, resolvers })
Assume the following directory structure:
.
├── a.graphql
├── b.graphql
└── c.graphql
a.graphql
# import B from "b.graphql"
type A {
# test 1
first: String
second: Float
b: B
}
b.graphql
# import C from 'c.graphql'
type B {
c: C
hello: String!
}
c.graphql
type C {
id: ID!
}
Running console.log(importSchema('a.graphql'))
produces the following output:
type A {
first: String
second: Float
b: B
}
type B {
c: C
hello: String!
}
type C {
id: ID!
}
It is possible to import from a root field like Query
;
queries.graphql
type Query {
feed: [Post!]!
drafts: [Post!]!
}
mutations.graphql
type Mutation {
publish(id: ID!): Post!
deletePost(id: ID!): Post!
}
schema.graphql
# import Query.* from "queries.graphql"
# import Mutation.publish from "mutations.graphql"
Running console.log(importSchema('schema.graphql'))
produces the following output:
type Query {
feed: [Post!]!
drafts: [Post!]!
}
type Mutation {
publish(id: ID!): Post!
}
You can also import every .graphql
files in your project using globs patterns.
Assume the following directory structure:
.
├── a.graphql
├── b.graphql
a.graphql
type Query {
first: String!
second: Float
}
b.graphql
type Book {
id: ID!
name: String
read: Boolean!
}
type Query {
book(id: ID!): Book
}
type Mutation {
readBook(id: ID!): Book
}
Running console.log(importSchema('*.graphql'))
produces the following output:
type Query {
first: String!
second: Float
book(id: ID!): Book
}
type Mutation {
readBook(id: ID!): Book
}
type Book {
id: ID!
name: String
read: Boolean!
}
Please refer to src/index.test.ts
for more examples.
The implementation documentation documents how things are implemented under the hood. You can also use the VSCode test setup to debug your code/tests.
FAQs
[](https://circleci.com/gh/prismagraphql/graphql-import) [](https://badge.fury.io/js/graphql-import)
We found that @fabien0102/graphql-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.