Gathering detailed insights and metrics for graphql-helix
Gathering detailed insights and metrics for graphql-helix
Gathering detailed insights and metrics for graphql-helix
Gathering detailed insights and metrics for graphql-helix
npm install graphql-helix
93.8
Supply Chain
100
Quality
78.5
Maintenance
100
Vulnerability
100
License
graphql-helix@1.13.0
Published on 09 Jul 2022
graphql-helix@1.12.0
Published on 08 Mar 2022
graphql-helix@1.11.0
Published on 16 Dec 2021
graphql-helix@1.10.3
Published on 25 Nov 2021
graphql-helix@1.10.2
Published on 19 Nov 2021
graphql-helix@1.10.1
Published on 18 Nov 2021
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
830 Stars
252 Commits
49 Forks
22 Watching
50 Branches
30 Contributors
Updated on 21 Nov 2024
Minified
Minified + Gzipped
TypeScript (96.48%)
CSS (2.48%)
JavaScript (1.04%)
Cumulative downloads
Total Downloads
Last day
-13.3%
2,318
Compared to previous day
Last week
32.2%
14,321
Compared to previous week
Last month
22.2%
55,917
Compared to previous month
Last year
-51.7%
589,266
Compared to previous year
A highly evolved GraphQL HTTP Server 🧬
GraphQL Helix is a collection of utility functions for building your own GraphQL HTTP server. You can check out Building a GraphQL server with GraphQL Helix on DEV for a detailed tutorial on getting started.
@defer
and @stream
directives.graphql-js
.npm install graphql-helix
yarn add graphql-helix
The following example shows how to integrate GraphQL Helix with Node.js using Express. This example shows how to implement all the basic features, including a GraphiQL interface, subscriptions and support for @stream
and @defer
. See the rest of the examples for implementations using other frameworks and runtimes. For implementing additional features, see the Recipes section below.
1import express, { RequestHandler } from "express";
2import { getGraphQLParameters, processRequest, renderGraphiQL, shouldRenderGraphiQL, sendResult } from "graphql-helix";
3import { schema } from "./schema";
4
5const app = express();
6
7app.use(express.json());
8
9app.use("/graphql", async (req, res) => {
10 // Create a generic Request object that can be consumed by Graphql Helix's API
11 const request = {
12 body: req.body,
13 headers: req.headers,
14 method: req.method,
15 query: req.query,
16 };
17
18 // Determine whether we should render GraphiQL instead of returning an API response
19 if (shouldRenderGraphiQL(request)) {
20 res.send(renderGraphiQL());
21 } else {
22 // Extract the Graphql parameters from the request
23 const { operationName, query, variables } = getGraphQLParameters(request);
24
25 // Validate and execute the query
26 const result = await processRequest({
27 operationName,
28 query,
29 variables,
30 request,
31 schema,
32 });
33
34 // processRequest returns one of three types of results depending on how the server should respond
35 // 1) RESPONSE: a regular JSON payload
36 // 2) MULTIPART RESPONSE: a multipart response (when @stream or @defer directives are used)
37 // 3) PUSH: a stream of events to push back down the client for a subscription
38 // The "sendResult" is a NodeJS-only shortcut for handling all possible types of Graphql responses,
39 // See "Advanced Usage" below for more details and customizations available on that layer.
40 sendResult(result, res);
41 }
42});
43
44const port = process.env.PORT || 4000;
45
46app.listen(port, () => {
47 console.log(`GraphQL server is running on port ${port}.`);
48});
The processRequest
will return one of the following types:
RESPONSE
: a regular JSON payloadMULTIPART_RESPONSE
: a multipart response (when @stream or @defer directives are used)PUSH
: a stream of events to push back down the client for a GraphQL subscriptionIf you GraphQL schema doesn't have the type Subscription
defined, or the @stream
/ @defer
/ @live
directives available, you'll get RESPONSE
in your result payload, so you can just use sendResult
helper to send the response data in one line of code.
If you wish to have more control over you transports, you can use one of the following exported helpers:
sendResponseResult
- matches the RESPONSE
type.sendMultipartResponseResult
- matches the MULTIPART_RESPONSE
type.sendPushResult
- matches the PUSH
type.And you'll be able to construct a custom flow. Here's a quick example for customizing the response per each type of result:
1if (result.type === "RESPONSE") {
2 sendResponseResult(result, res);
3} else if (result.type === "MULTIPART_RESPONSE") {
4 sendMultipartResponseResult(result, res);
5} else if (result.type === "PUSH") {
6 sendPushResult(result, res);
7}
This way you can also disable specific responses if you wish, by return an error instead of calling the helpers.
Checkout docs to learn more.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/14 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
50 existing vulnerabilities detected
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