Gathering detailed insights and metrics for @graphql-tools/merge
Gathering detailed insights and metrics for @graphql-tools/merge
Gathering detailed insights and metrics for @graphql-tools/merge
Gathering detailed insights and metrics for @graphql-tools/merge
@graphql-tools/executor
Fork of GraphQL.js' execute function
@graphql-tools/optimize
A set of utils for faster development of GraphQL tools
graphql-config
The easiest way to configure your development environment with your GraphQL schema (supported by most tools, editors & IDEs)
@graphql-tools/documents
Utilities for GraphQL documents.
🔧 Utility library for GraphQL to build, stitch and mock GraphQL schemas in the SDL-first approach
npm install @graphql-tools/merge
November 27, 2024
Published on 27 Nov 2024
November 22, 2024
Published on 22 Nov 2024
November 13, 2024
Published on 13 Nov 2024
November 08, 2024
Published on 08 Nov 2024
November 01, 2024
Published on 01 Nov 2024
October 31, 2024
Published on 31 Oct 2024
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5,356 Stars
6,179 Commits
818 Forks
78 Watching
30 Branches
384 Contributors
Updated on 28 Nov 2024
TypeScript (90.74%)
MDX (8.17%)
JavaScript (1.07%)
Shell (0.02%)
Cumulative downloads
Total Downloads
Last day
-7.9%
1,649,613
Compared to previous day
Last week
3.8%
9,346,331
Compared to previous week
Last month
6.9%
38,771,800
Compared to previous month
Last year
5.8%
423,956,840
Compared to previous year
2
1
This package provides a few useful ways to create a GraphQL schema:
If you want to bind your JavaScript GraphQL schema to an HTTP server, you can use
GraphQL Yoga
.
You can develop your JavaScript based GraphQL API with graphql-tools
and GraphQL Yoga
together:
One to write the schema and resolver code, and the other to connect it to a web server.
When using graphql-tools
, you describe the schema as a GraphQL type language string:
1const typeDefs = /* GraphQL */ ` 2 type Author { 3 id: ID! # the ! means that every author object _must_ have an id 4 firstName: String 5 lastName: String 6 """ 7 the list of Posts by this author 8 """ 9 posts: [Post] 10 } 11 12 type Post { 13 id: ID! 14 title: String 15 author: Author 16 votes: Int 17 } 18 19 # the schema allows the following query: 20 type Query { 21 posts: [Post] 22 } 23 24 # this schema allows the following mutation: 25 type Mutation { 26 upvotePost(postId: ID!): Post 27 } 28 29 # we need to tell the server which types represent the root query 30 # and root mutation types. We call them RootQuery and RootMutation by convention. 31 schema { 32 query: Query 33 mutation: Mutation 34 } 35` 36 37export default typeDefs
Then you define resolvers as a nested object that maps type and field names to resolver functions:
1const resolvers = { 2 Query: { 3 posts() { 4 return posts 5 } 6 }, 7 Mutation: { 8 upvotePost(_, { postId }) { 9 const post = find(posts, { id: postId }) 10 if (!post) { 11 throw new Error(`Couldn't find post with id ${postId}`) 12 } 13 post.votes += 1 14 return post 15 } 16 }, 17 Author: { 18 posts(author) { 19 return filter(posts, { authorId: author.id }) 20 } 21 }, 22 Post: { 23 author(post) { 24 return find(authors, { id: post.authorId }) 25 } 26 } 27} 28 29export default resolvers
At the end, the schema and resolvers are combined using makeExecutableSchema
:
1import { makeExecutableSchema } from '@graphql-tools/schema' 2 3const executableSchema = makeExecutableSchema({ 4 typeDefs, 5 resolvers 6})
GraphQL-Tools schema can be consumed by frameworks like GraphQL Yoga, Apollo GraphQL or express-graphql For example in Node.js;
1const { createYoga } = require('graphql-yoga') 2const { createServer } = require('http') 3 4const yoga = createYoga({ 5 schema: executableSchema 6}) 7 8const server = createServer(yoga) 9 10server.listen(4000, () => { 11 console.log('Yoga is listening at http://localhost:4000/graphql') 12})
You can check GraphQL Yoga for other JavaScript platforms and frameworks besides vanilla Node.js HTTP.
This example has the entire type definition in one string and all resolvers in one file, but you can combine types and resolvers from multiple files and objects, as documented in the modularizing type definitions and merging resolvers section of the docs.
Contributions, issues and feature requests are very welcome. If you are using this package and fixed a bug for yourself, please consider submitting a PR!
And if this is your first time contributing to this project, please do read our Contributor Workflow Guide before you get started off.
Help us keep GraphQL Tools open and inclusive. Please read and follow our Code of Conduct as adopted from Contributor Covenant
No vulnerabilities found.
Reason
30 commit(s) and 10 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
Found 1/21 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More