{"id":13550538,"url":"https://github.com/zalando-incubator/graphql-jit","last_synced_at":"2025-05-13T20:19:16.997Z","repository":{"id":38375621,"uuid":"152671477","full_name":"zalando-incubator/graphql-jit","owner":"zalando-incubator","description":"GraphQL execution using a JIT compiler","archived":false,"fork":false,"pushed_at":"2024-11-18T22:43:36.000Z","size":851,"stargazers_count":1066,"open_issues_count":31,"forks_count":59,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-05-05T17:32:08.263Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://try-graphql-jit.boopathi.in/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalando-incubator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-12T00:23:19.000Z","updated_at":"2025-04-30T21:43:56.000Z","dependencies_parsed_at":"2023-02-16T07:00:48.565Z","dependency_job_id":"60866c9d-eb8b-4c1e-a16b-65052070f1f9","html_url":"https://github.com/zalando-incubator/graphql-jit","commit_stats":{"total_commits":196,"total_committers":34,"mean_commits":5.764705882352941,"dds":0.7295918367346939,"last_synced_commit":"114943de27e9d53a84a5a92f39d774b1d5babe14"},"previous_names":["ruiaraujo/graphql-jit"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fgraphql-jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fgraphql-jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fgraphql-jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fgraphql-jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalando-incubator","download_url":"https://codeload.github.com/zalando-incubator/graphql-jit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020659,"owners_count":22000757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:01:34.485Z","updated_at":"2025-05-13T20:19:16.964Z","avatar_url":"https://github.com/zalando-incubator.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Implementations","others"],"sub_categories":["JavaScript/TypeScript"],"readme":"# GraphQL JIT\n\n![npm](https://img.shields.io/npm/dw/graphql-jit)\n[![codecov](https://codecov.io/gh/zalando-incubator/graphql-jit/branch/main/graph/badge.svg)](https://codecov.io/gh/zalando-incubator/graphql-jit)\n\n### Why?\n\nGraphQL-JS is a very well written runtime implementation of the latest GraphQL spec. However, by compiling to JS, V8 is able to create optimized\ncode 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](#benchmarks) below)\n\n#### Benchmarks\n\nGraphQL-JS 16 on Node 16.13.0\n\n```bash\n$ yarn benchmark skip-json\nStarting introspection\ngraphql-js x 1,941 ops/sec ±2.50% (225 runs sampled)\ngraphql-jit x 6,158 ops/sec ±2.38% (222 runs sampled)\nStarting fewResolvers\ngraphql-js x 26,620 ops/sec ±2.41% (225 runs sampled)\ngraphql-jit x 339,223 ops/sec ±2.94% (215 runs sampled)\nStarting manyResolvers\ngraphql-js x 16,415 ops/sec ±2.36% (220 runs sampled)\ngraphql-jit x 178,331 ops/sec ±2.73% (221 runs sampled)\nStarting nestedArrays\ngraphql-js x 127 ops/sec ±1.43% (220 runs sampled)\ngraphql-jit x 1,316 ops/sec ±2.58% (219 runs sampled)\nDone in 141.25s.\n```\n\n### Support for GraphQL spec\n\nThe goal is to support the [June 2018 version of the GraphQL spec](https://facebook.github.io/graphql/June2018/).\n\n#### Differences to `graphql-js`\n\nIn order to achieve better performance, the `graphql-jit` compiler introduces some limitations.\nThe primary limitation is that all computed properties must have a resolver and only these can return a `Promise`.\n\nMore details here - [GraphQL-JS.md](./GraphQL-JS.md)\n\n## Install\n\n```sh\nyarn add graphql-jit\n```\n\n## Example\n\nFor complete working examples, check the [examples/](examples) directory\n\n#### Create a schema\n\n```js\nconst typeDefs = `\ntype Query {\n  hello: String\n}\n`;\nconst resolvers = {\n  Query: {\n    hello() {\n      return new Promise((resolve) =\u003e setTimeout(() =\u003e resolve(\"World!\"), 200));\n    }\n  }\n};\n\nconst { makeExecutableSchema } = require(\"@graphql-tools/schema\");\nconst schema = makeExecutableSchema({ typeDefs, resolvers });\n```\n\n#### Compile a Query\n\n```js\nconst query = `\n{\n  hello\n}\n`;\nconst { parse } = require(\"graphql\");\nconst document = parse(query);\n\nconst { compileQuery, isCompiledQuery } = require(\"graphql-jit\");\nconst compiledQuery = compileQuery(schema, document);\n// check if the compilation is successful\n\nif (!isCompiledQuery(compiledQuery)) {\n  console.error(compiledQuery);\n  throw new Error(\"Error compiling query\");\n}\n```\n\n#### Execute the Query\n\n```js\nconst executionResult = await compiledQuery.query(root, context, variables);\nconsole.log(executionResult);\n```\n\n#### Subscribe to the Query\n\n```js\nconst result = await compiledQuery.subscribe(root, context, variables);\nfor await (const value of result) {\n  console.log(value);\n}\n```\n\n## API\n\n### compiledQuery = compileQuery(schema, document, operationName, compilerOptions)\n\nCompiles the `document` AST, using an optional operationName and compiler options.\n\n- `schema` {GraphQLSchema} - `graphql` schema object\n- `document` {DocumentNode} - document query AST ,can be obtained by `parse` from `graphql`\n- `operationName` {string} - optional operation name in case the document contains multiple [operations](http://spec.graphql.org/draft/#sec-Language.Operations)(queries/mutations/subscription).\n- `compilerOptions` {Object} - Configurable options for the compiler\n\n  - `disableLeafSerialization` {boolean, default: false} - disables leaf node serializers. The serializers validate the content of the field at runtime\n    so this option should only be set to true if there are strong assurances that the values are valid.\n  - `customSerializers` {Object as Map, default: {}} - Replace serializer functions for specific types. Can be used as a safer alternative\n    for overly expensive serializers\n  - `customJSONSerializer` {boolean, default: false} - Whether to produce also a JSON serializer function using `fast-json-stringify`. The default stringifier function is `JSON.stringify`\n\n#### compiledQuery.query(root: any, context: any, variables: Maybe\u003c{ [key: string]: any }\u003e)\n\nthe compiled function that can be called with a root value, a context and the required variables.\n\n#### compiledQuery.subscribe(root: any, context: any, variables: Maybe\u003c{ [key: string]: any }\u003e)\n\n(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).\n\n#### compiledQuery.stringify(value: any)\n\nthe compiled function for producing a JSON string. It will be `JSON.stringify` unless `compilerOptions.customJSONSerializer` is true.\nThe value argument should be the return of the compiled GraphQL function.\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando-incubator%2Fgraphql-jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalando-incubator%2Fgraphql-jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando-incubator%2Fgraphql-jit/lists"}