{"id":26533802,"url":"https://github.com/graphql-hive/envelop","last_synced_at":"2025-05-14T21:07:32.546Z","repository":{"id":36966687,"uuid":"339674565","full_name":"graphql-hive/envelop","owner":"graphql-hive","description":"Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system. ","archived":false,"fork":false,"pushed_at":"2025-05-10T18:55:30.000Z","size":20472,"stargazers_count":811,"open_issues_count":120,"forks_count":131,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-11T19:44:56.868Z","etag":null,"topics":["api","execution-pipeline","graphql","graphql-execution","graphql-schema","javascript","nodejs","plugins","the-guild","typescript"],"latest_commit_sha":null,"homepage":"https://envelop.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-hive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":"https://www.buymeacoffee.com/JDnuAwr"}},"created_at":"2021-02-17T09:42:09.000Z","updated_at":"2025-05-10T02:48:00.000Z","dependencies_parsed_at":"2023-12-19T01:10:46.617Z","dependency_job_id":"9b19e2ab-f9a6-418b-a27e-bc5593c067f2","html_url":"https://github.com/graphql-hive/envelop","commit_stats":{"total_commits":1791,"total_committers":79,"mean_commits":"22.670886075949365","dds":0.371859296482412,"last_synced_commit":"eb5382df092a83a03b0f94a96b093b30b31c0b5a"},"previous_names":["dotansimha/envelop","graphql-hive/envelop"],"tags_count":1544,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-hive%2Fenvelop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-hive%2Fenvelop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-hive%2Fenvelop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-hive%2Fenvelop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-hive","download_url":"https://codeload.github.com/graphql-hive/envelop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929376,"owners_count":21985804,"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":["api","execution-pipeline","graphql","graphql-execution","graphql-schema","javascript","nodejs","plugins","the-guild","typescript"],"created_at":"2025-03-21T19:20:38.893Z","updated_at":"2025-05-14T21:07:27.526Z","avatar_url":"https://github.com/graphql-hive.png","language":"TypeScript","readme":"[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/bdb8cd5d-5186-4ece-b06b-b00a499b7868)](https://graphql.org/conf/2024/?utm_source=github\u0026utm_medium=envelop\u0026utm_campaign=readme)\n\n## Envelop\n\n`envelop` is a lightweight JavaScript (/TypeScript) library for wrapping GraphQL execution layer and\nflow, allowing developers to develop, share and collaborate on GraphQL-related plugins while filling\nthe missing pieces in GraphQL implementations.\n\n`envelop` aims to extend the GraphQL execution flow by adding plugins that enrich the feature set of\nyour application.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg height=\"150\" src=\"./logo.png\"\u003e\n\u003c/p\u003e\n\n`@envelop/core`:\n[![npm version](https://badge.fury.io/js/%40envelop%2Fcore.svg)](https://www.npmjs.com/package/@envelop/core)\n\n\u003e Envelop is created and maintained by [The Guild](https://the-guild.dev/), and used in production\n\u003e by our clients.\n\n### [Envelop Key Concepts](\u003c(https://www.envelop.dev/docs#key-concepts)\u003e)\n\n- Lightweight\n- Wraps the entire GraphQL pipeline, based on plugins\n- Low-level API for extending the execution layer\n- Agnostic to GraphQL Engine\n- Agnostic to the HTTP layer\n- Agnostic to the schema tools\n- Plugins-based usage\n- No vendor lock-in\n- Amazing TypeScript support\n\n[You can read more about the key concepts or Envelop here](https://www.envelop.dev/docs#key-concepts)\n\n## [Getting Started](https://www.envelop.dev/docs/getting-started)\n\nStart by adding the core of Envelop to your codebase:\n\n```\nyarn add graphql @envelop/core\n```\n\nThen, create a simple Envelop based on your GraphQL schema:\n\n```ts\nimport * as GraphQLJS from 'graphql'\nimport { envelop, useEngine, useSchema } from '@envelop/core'\n\nconst mySchema = buildSchema(/* ... */) // GraphQLSchema\n\nconst getEnveloped = envelop({\n  plugins: [useEngine(GraphQLJS), useSchema(mySchema)]\n})\n```\n\nThe result of `envelop` is a function that allows you to get everything you need for the GraphQL\nexecution: `parse`, `validate`, `contextBuilder` and `execute`. Use that to run the client's GraphQL\nqueries. Here's a pseudo-code example of how it should look like:\n\n```ts\nconst httpServer = createServer()\n\nhttpServer.on('request', async (req, res) =\u003e {\n  // Here you get the alternative methods that are bundled with your plugins\n  // You can also pass the \"req\" to make it available for your plugins or GraphQL context.\n  const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req })\n\n  // Parse the initial request and validate it\n  const { query, variables } = JSON.parse(req.payload)\n  const document = parse(query)\n  const validationErrors = validate(schema, document)\n\n  if (validationErrors.length \u003e 0) {\n    return res.end(JSON.stringify({ errors: validationErrors }))\n  }\n\n  // Build the context and execute\n  const context = await contextFactory(req)\n  const result = await execute({\n    document,\n    schema,\n    variableValues: variables,\n    contextValue: context\n  })\n\n  // Send the response\n  res.end(JSON.stringify(result))\n})\n\nhttpServer.listen(3000)\n```\n\nBehind the scenes, this simple workflow allows you to use **Envelop plugins** and hook into the\nentire request handling flow.\n\nHere's a simple example for collecting metrics and logging all incoming requests, using the built-in\nplugins:\n\n```ts\nconst getEnveloped = envelop({\n  plugins: [useEngine(GraphQLJS), useSchema(schema), useLogger(), useTiming()]\n})\n```\n\n\u003e [You can read more about here](https://www.envelop.dev/docs/getting-started)\n\n## [Integrations / Examples](https://www.envelop.dev/docs/integrations)\n\n[You can find the integrations and compatibility list, and code-based examples here](https://www.envelop.dev/docs/integrations)\n\n## Available Plugins\n\nYou can explore all plugins in our [Plugins Hub](https://www.envelop.dev/plugins). If you wish your\nplugin to be listed here and under PluginsHub, feel free to add your plugin information\n[in this file](https://github.com/graphql-hive/envelop/edit/main/website/src/lib/plugins.ts#L23) and\ncreate a Pull Request!\n\nWe provide a few built-in plugins within the `@envelop/core`, and many more plugins as standalone\npackages.\n\n**[Envelop's Plugin Hub](https://www.envelop.dev/plugins)**\n\n## Sharing / Composing `envelop`s\n\nAfter an `envelop` has been created, you can share it with others as a complete layer of plugins.\nThis is useful if you wish to create a predefined layer of plugins, and share it with others. You\ncan use it as a shell and as a base for writing shareable pieces of servers.\n\nYou can read more about\n[Sharing and Composing Envelops here](https://www.envelop.dev/docs/composing-envelop).\n\n## Write your own plugin!\n\nEnvelop plugins are just objects with functions, that provide contextual implementation for\nbefore/after each phase, with a flexible API.\n\nHere's a simple example that allows you to print the execution params:\n\n```ts\nconst myPlugin = {\n  onExecute({ args }) {\n    console.log('Execution started!', { args })\n\n    return {\n      onExecuteDone({ result }) {\n        console.log('Execution done!', { result })\n      }\n    }\n  }\n}\n\nconst getEnveloped = envelop({\n  plugins: [\n    /// ... other plugins ...,\n    myPlugin\n  ]\n})\n```\n\n[For a complete guide and API docs for custom plugins, please refer to Envelop website](https://www.envelop.dev/docs/plugins)\n\n### Contributing\n\nIf this is your first time contributing to this project, please do read our\n[Contributor Workflow Guide](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md)\nbefore you get started off.\n\nFeel free to open issues and pull requests. We always welcome support from the community.\n\n### Code of Conduct\n\nHelp us keep Envelop open and inclusive. Please read and follow our\n[Code of Conduct](https://github.com/the-guild-org/Stack/blob/master/CODE_OF_CONDUCT.md) as adopted\nfrom [Contributor Covenant](https://www.contributor-covenant.org/)\n\n### License\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)](https://raw.githubusercontent.com/apollostack/apollo-ios/master/LICENSE)\n\nMIT\n","funding_links":["https://www.buymeacoffee.com/JDnuAwr"],"categories":["TypeScript","Others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-hive%2Fenvelop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-hive%2Fenvelop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-hive%2Fenvelop/lists"}