Gathering detailed insights and metrics for graphql-jit
Gathering detailed insights and metrics for graphql-jit
Gathering detailed insights and metrics for graphql-jit
Gathering detailed insights and metrics for graphql-jit
@envelop/graphql-jit
This plugins replaces the original `execute` of GraphQL with [`graphql-jit`](https://github.com/zalando-incubator/graphql-jit).
@hoangvvo/graphql-jit
GraphQL JIT Compiler to JS
@benzene/jit
GraphQL JIT implementation for @benzene/core
@graphql-codegen/typescript-jit-sdk
GraphQL Code Generator plugin for generating a ready-to-use SDK that uses GraphQL JIT
npm install graphql-jit
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,049 Stars
197 Commits
57 Forks
19 Watching
11 Branches
34 Contributors
Updated on 14 Nov 2024
TypeScript (98.32%)
JavaScript (1.68%)
Cumulative downloads
Total Downloads
Last day
-9.5%
23,244
Compared to previous day
Last week
14.1%
137,452
Compared to previous week
Last month
10.1%
527,532
Compared to previous month
Last year
218.7%
8,299,075
Compared to previous year
6
1
30
GraphQL-JS is a very well written runtime implementation of the latest GraphQL spec. However, by compiling to JS, V8 is able to create optimized
code which yields much better performance. graphql-jit
leverages this behaviour of V8 optimization by compiling the queries into functions to significantly improve performance (See benchmarks below)
GraphQL-JS 16 on Node 16.13.0
1$ yarn benchmark skip-json 2Starting introspection 3graphql-js x 1,941 ops/sec ±2.50% (225 runs sampled) 4graphql-jit x 6,158 ops/sec ±2.38% (222 runs sampled) 5Starting fewResolvers 6graphql-js x 26,620 ops/sec ±2.41% (225 runs sampled) 7graphql-jit x 339,223 ops/sec ±2.94% (215 runs sampled) 8Starting manyResolvers 9graphql-js x 16,415 ops/sec ±2.36% (220 runs sampled) 10graphql-jit x 178,331 ops/sec ±2.73% (221 runs sampled) 11Starting nestedArrays 12graphql-js x 127 ops/sec ±1.43% (220 runs sampled) 13graphql-jit x 1,316 ops/sec ±2.58% (219 runs sampled) 14Done in 141.25s.
The goal is to support the June 2018 version of the GraphQL spec.
graphql-js
In order to achieve better performance, the graphql-jit
compiler introduces some limitations.
The primary limitation is that all computed properties must have a resolver and only these can return a Promise
.
More details here - GraphQL-JS.md
1yarn add graphql-jit
For complete working examples, check the examples/ directory
1const typeDefs = ` 2type Query { 3 hello: String 4} 5`; 6const resolvers = { 7 Query: { 8 hello() { 9 return new Promise((resolve) => setTimeout(() => resolve("World!"), 200)); 10 } 11 } 12}; 13 14const { makeExecutableSchema } = require("@graphql-tools/schema"); 15const schema = makeExecutableSchema({ typeDefs, resolvers });
1const query = ` 2{ 3 hello 4} 5`; 6const { parse } = require("graphql"); 7const document = parse(query); 8 9const { compileQuery, isCompiledQuery } = require("graphql-jit"); 10const compiledQuery = compileQuery(schema, document); 11// check if the compilation is successful 12 13if (!isCompiledQuery(compiledQuery)) { 14 console.error(compiledQuery); 15 throw new Error("Error compiling query"); 16}
1const executionResult = await compiledQuery.query(root, context, variables); 2console.log(executionResult);
1const result = await compiledQuery.subscribe(root, context, variables); 2for await (const value of result) { 3 console.log(value); 4}
Compiles the document
AST, using an optional operationName and compiler options.
schema
{GraphQLSchema} - graphql
schema object
document
{DocumentNode} - document query AST ,can be obtained by parse
from graphql
operationName
{string} - optional operation name in case the document contains multiple operations(queries/mutations/subscription).
compilerOptions
{Object} - Configurable options for the compiler
disableLeafSerialization
{boolean, default: false} - disables leaf node serializers. The serializers validate the content of the field at runtime
so this option should only be set to true if there are strong assurances that the values are valid.customSerializers
{Object as Map, default: {}} - Replace serializer functions for specific types. Can be used as a safer alternative
for overly expensive serializerscustomJSONSerializer
{boolean, default: false} - Whether to produce also a JSON serializer function using fast-json-stringify
. The default stringifier function is JSON.stringify
the compiled function that can be called with a root value, a context and the required variables.
(available for GraphQL Subscription only) the compiled function that can be called with a root value, a context and the required variables to produce either an AsyncIterator (if successful) or an ExecutionResult (error).
the compiled function for producing a JSON string. It will be JSON.stringify
unless compilerOptions.customJSONSerializer
is true.
The value argument should be the return of the compiled GraphQL function.
MIT
No vulnerabilities found.
Reason
12 commit(s) and 1 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
Found 20/26 approved changesets -- score normalized to 7
Reason
6 existing vulnerabilities detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
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-18
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