{"name":"@envelop/core","version":"0.1.4-alpha-831a172.0","sideEffects":false,"peerDependencies":{"graphql":"^14.0.0 || ^15.0.0"},"dependencies":{"@envelop/types":"0.1.4-alpha-831a172.0"},"repository":{"type":"git","url":"git+https://github.com/dotansimha/envelop.git","directory":"packages/core"},"keywords":["gql","graphql","server","framework","node","nodejs","typescript"],"author":{"name":"Dotan Simha","email":"dotansimha@gmail.com"},"license":"MIT","main":"index.cjs.js","module":"index.esm.js","typings":"index.d.ts","typescript":{"definition":"index.d.ts"},"readme":"## `@envelop/core`\n\nThis is the core package for Envelop. You can find a complete documentation here: https://github.com/dotansimha/envelop\n\n### Built-in plugins\n\n#### `useSchema`\n\nThis plugin is the simplest plugin for specifying your GraphQL schema. You can specify a schema created from any tool that emits `GraphQLSchema` object.\n\n```ts\nimport { envelop, useSchema } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst mySchema = buildSchema(...);\n\nconst getEnveloped = envelop({\n  plugins: [\n    useSchema(mySchema),\n    // ... other plugins ...\n  ],\n});\n```\n\n#### `useErrorHandler`\n\nThis plugin triggers a custom function every time execution encounter an error.\n\n```ts\nimport { envelop, useErrorHandler } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst getEnveloped = envelop({\n  plugins: [\n    useErrorHandler(error => {\n      // This callback is called per each GraphQLError emitted during execution phase\n    }),\n    // ... other plugins ...\n  ],\n});\n```\n\n> Note: every error is being triggered on it's own. So an execution results will multiple error will yield multiple calls.\n\n#### `useExtendContext`\n\nEasily extends the context with custom fields.\n\n```ts\nimport { envelop, useExtendContext } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst getEnveloped = envelop({\n  plugins: [\n    useExtendContext(async (contextSoFar) => {\n      return {\n        myCustomField: { ... }\n      }\n    }),\n    // ... other plugins ...\n  ],\n});\n```\n\n#### `useLogger`\n\nLogs paramaters and information about the execution phases. You can easily plug your custom logger.\n\n```ts\nimport { envelop, useLogger } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst getEnveloped = envelop({\n  plugins: [\n    useLogger({\n      logFn: (eventName, args) => {\n        // Event could be `execute-start` / `execute-end` / `subscribe-start` / `subscribe-end`\n        // `args` will include the arguments passed to execute/subscribe (in case of \"start\" event) and additional result in case of \"end\" event.\n      },\n    }),\n    // ... other plugins ...\n  ],\n});\n```\n\n#### `usePayloadFormatter`\n\nAllow you to format/modify execution result payload before returning it to your consumer.\n\n```ts\nimport { envelop, usePayloadFormatter } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst getEnveloped = envelop({\n  plugins: [\n    usePayloadFormatter(result => {\n      // Return a modified result here,\n      // Or `false`y value to keep it as-is.\n    }),\n    // ... other plugins ...\n  ],\n});\n```\n\n#### `useTiming`\n\nSimple time metric collection, for every phase in your execution. You can easily customize the behaviour of each timing measurement. By default, the timing is printed to the log, using `console.log`.\n\n```ts\nimport { envelop, useTiming } from '@envelop/core';\nimport { buildSchema } from 'graphql';\n\nconst getEnveloped = envelop({\n  plugins: [\n    useTiming({\n      // All options are optional. By default it just print it to the log.\n      // ResultTiming is an object built with { ms, ns } (milliseconds and nanoseconds)\n      onContextBuildingMeasurement: (timing: ResultTiming) => {},\n      onExecutionMeasurement: (args: ExecutionArgs, timing: ResultTiming) => {},\n      onSubscriptionMeasurement: (args: SubscriptionArgs, timing: ResultTiming) => {},\n      onParsingMeasurement: (source: Source | string, timing: ResultTiming) => {},\n      onValidationMeasurement: (document: DocumentNode, timing: ResultTiming) => {},\n      onResolverMeasurement: (info: GraphQLResolveInfo, timing: ResultTiming) => {},\n    }),\n    // ... other plugins ...\n  ],\n});\n```\n","readmeFilename":"README.md","description":"This is the core package for Envelop. You can find a complete documentation here: https://github.com/dotansimha/envelop","bugs":{"url":"https://github.com/dotansimha/envelop/issues"},"homepage":"https://github.com/dotansimha/envelop#readme","_id":"@envelop/core@0.1.4-alpha-831a172.0","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-Hfw0eZUu5cVs6/vab8rQNwxdaddqvkDbw8xFk6E/SEYCDr4LRegsDVj+Kl0gbuxdBvR6LOtE6TBV6C5PemSa9w==","shasum":"02e484740bdf494186f2b331bde8a68cafeaeb2b","tarball":"http://registry-npm.ywwl.com/@envelop/core/download/@envelop/core-0.1.4-alpha-831a172.0.tgz","fileCount":14,"unpackedSize":115173,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjrQSCRA9TVsSAnZWagAAUo4P/RNZMhlRG+V6kk7/CXFK\nIBv0s50LEX+MP/Ozk9yZqOxaWLckkiFVCtuX4ZsOxRxUi7tH0GFUryWFdx8F\naVuEE0mWKqiZ/BVU6Qwl5HyDQ5819gor8CS8cNTuAMHFlPSlyUeqnI/IDbc9\nZWpEGTR2R+PqayyrHj5uM2Jj4EAtLR/giVAf1Q7Q9Cxi8qQCkpMHP4VW1tOC\nyYACQda61vstVl5+qgxcK3SKzRo230nhd31vp5z7ary4lvBX4IhwNVTZIl38\nnafKTXEWWiEJN9uZ55YEVDUcryNTTMdMEJGTBdsWaz3zfxMptrt252cc0WzZ\n3o4NyVWdaCDYJppK81540QCumMecqn03xZwKQ4fnSDiXxx3BWP8LBzp++20M\nRoQOcPrSaeOAXuHNhg23swUF2zZEj/zzK/Os5xR6IOuW+Al9JylXXfVi413O\nokD71cGfY8CkkwHup2T3X1bxiWE1QN8w5iqWCahErzeRqLpGZV2Wtp6moEVm\ni8WWFqM8CILeqJEPMIdU8FalRznk3E2S3FJ5OAXpsSb5uQ1XVHU42U/huYQF\nExLplV+J94xBm768cYxL9+3lqUuIH/ay0wgEo3gey70il24UDxotGZQjDFmv\ned9+fd6BTnN0fDlLTMm/IgH3wIDBzDziKu3IeCvknleQnGKKd5u72+5fhHva\nYoIM\r\n=cl6m\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBtSeVIo6pc5P8Xz1odJhNz9/qcVFu11Xo4M9CzRP3lzAiAJnud27OZlsDQmO1KmW3fPiL++xf3qzNMMNYZjnWrj0g=="}],"size":16163,"noattachment":false,"key":"/@envelop/core/-/@envelop/core-0.1.4-alpha-831a172.0.tgz"},"_npmUser":{"name":"dotansimha","email":"dotansimha@gmail.com"},"directories":{},"maintainers":[{"name":"dotansimha","email":"dotansimha@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_0.1.4-alpha-831a172.0_1619964946029_0.11425486855355671"},"_hasShrinkwrap":false,"publish_time":1619964946152,"_cnpm_publish_time":1619964946152,"dist-tags":{"alpha":"6.0.2-alpha-20261126100851-58d9782f151a975e802f1a545a315263d8d886a7","latest":"6.0.1","rc":"6.0.2-rc-20261124205929-9595907fc2bef8a397343bd288fef4685ab9f508"}}