{"name":"@envelop/live-query","version":"3.0.1-alpha-0d78849.0","sideEffects":false,"peerDependencies":{"@envelop/core":"2.0.1-alpha-0d78849.0","graphql":"^14.0.0 || ^15.0.0 || ^16.0.0"},"dependencies":{"@graphql-tools/utils":"^8.6.1","@n1ru4l/graphql-live-query":"^0.9.0","@n1ru4l/in-memory-live-query-store":"^0.9.0"},"repository":{"type":"git","url":"git+https://github.com/dotansimha/envelop.git","directory":"packages/plugins/live-query"},"author":{"name":"Dotan Simha","email":"dotansimha@gmail.com"},"license":"MIT","main":"index.js","module":"index.mjs","typings":"index.d.ts","typescript":{"definition":"index.d.ts"},"exports":{".":{"require":"./index.js","import":"./index.mjs"},"./*":{"require":"./*.js","import":"./*.mjs"},"./package.json":"./package.json"},"readme":"## `@envelop/live-query`\n\nThe easiest way of adding live queries to your GraphQL server!\n\nPush new data to your clients automatically once the data selected by a GraphQL operation becomes stale by annotating your query operation with the `@live` directive.\n\n```graphql\nquery UserProfile @live {\n  me {\n    id\n    login\n    bio\n  }\n}\n```\n\nThe invalidation mechanism is based on GraphQL ID fields and schema coordinates. Once a query operation has been invalidated, the query is re-executed and the result is pushed to the client.\n\n## Installation\n\n```bash\nyarn add @envelop/live-query @n1ru4l/in-memory-live-query-store\n```\n\n## Usage Example\n\n### `makeExecutableSchema` from `graphql-tools`\n\n```ts\nimport { envelop, useSchema, useExtendContext } from '@envelop/core';\nimport { useLiveQuery } from '@envelop/live-query';\nimport { InMemoryLiveQueryStore } from '@n1ru4l/in-memory-live-query-store';\nimport { makeExecutableSchema } from '@graphql-tools/schema';\n\nconst schema = makeExecutableSchema({\n  typeDefs: [\n    /* GraphQL */ `\n      type Query {\n        greetings: [String!]\n      }\n    `,\n    GraphQLLiveDirectiveSDL,\n  ],\n  resolvers: {\n    Query: {\n      greetings: (_, __, context) => context.greetings,\n    },\n  },\n});\n\nconst liveQueryStore = new InMemoryLiveQueryStore();\n\nconst greetings = ['Hello', 'Hi', 'Ay', 'Sup'];\n// Shuffle greetings and invalidate queries selecting Query.greetings every second.\nsetInterval(() => {\n  const firstElement = greetings.pop();\n  greetings.unshift(firstElement);\n  liveQueryStore.invalidate('Query.greetings');\n}, 1000);\n\nconst getEnveloped = envelop({\n  plugins: [\n    useSchema(schema),\n    useLiveQuery({ liveQueryStore }),\n    useExtendContext(() => ({ greetings })),\n    /* other plugins */\n  ],\n});\n```\n\n### `GraphQLSchema` from `graphql`\n\nYou need to pass the `GraphQLLiveDirective` to the list of directives:\n\n```tsx\nimport { GraphQLSchema } from 'graphql';\nimport { GraphQLLiveDirective } from '@envelop/live-query';\n\nconst schema = new GraphQLSchema({\n  directives: [...specifiedDirectives, GraphQLLiveDirective],\n});\n```\n\n## Further information\n\nThis plugin requires you to use a graphql transports that supports usage of the `@defer` and `@stream` directives, as it is built upon the same concepts (return an `AsyncIterable` from `execute`).\n\nThe following transports have been successfully tested:\n\n| Package                                                                                                                          | Transport                                                                                   | Version                                                                                                                                                                         | Downloads                                                                                                                                                                          |\n| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [`@n1ru4l/socket-io-graphql-server`](https://github.com/n1ru4l/graphql-live-queries/blob/main/packages/socket-io-graphql-server) | GraphQL over Socket.io (WebSocket/HTTP Long Polling)                                        | [![npm version](https://badge.fury.io/js/%40n1ru4l%2Fsocket-io-graphql-server.svg)](https://github.com/n1ru4l/graphql-live-queries/blob/main/packages/socket-io-graphql-server) | [![npm downloads](https://img.shields.io/npm/dm/@n1ru4l/socket-io-graphql-server.svg)](https://github.com/n1ru4l/graphql-live-queries/blob/main/packages/socket-io-graphql-server) |\n| [`graphql-helix`](https://github.com/danielrearden/graphql-helix)                                                                | [GraphQL over HTTP](https://github.com/graphql/graphql-over-http) (IncrementalDelivery/SSE) | [![npm version](https://badge.fury.io/js/graphql-helix.svg)](https://github.com/danielrearden/graphql-helix)                                                                    | [![npm downloads](https://img.shields.io/npm/dm/graphql-helix.svg)](https://github.com/danielrearden/graphql-helix)                                                                |\n| [`graphql-ws`](https://github.com/enisdenjo/graphql-ws)                                                                          | [GraphQL over WebSocket](https://github.com/graphql/graphql-over-http/pull/140) (WebSocket) | [![npm version](https://badge.fury.io/js/graphql-ws.svg)](https://github.com/enisdenjo/graphql-ws)                                                                              | [![npm downloads](https://img.shields.io/npm/dm/graphql-ws.svg)](https://github.com/enisdenjo/graphql-ws)                                                                          |\n| [`graphql-sse`](https://github.com/enisdenjo/graphql-sse)                                                                          | [GraphQL over Server-Sent Events](https://github.com/enisdenjo/graphql-sse/blob/master/PROTOCOL.md) (SSE) | [![npm version](https://badge.fury.io/js/graphql-sse.svg)](https://github.com/enisdenjo/graphql-sse)                                                                              | [![npm downloads](https://img.shields.io/npm/dm/graphql-sse.svg)](https://github.com/enisdenjo/graphql-sse)                                                                          |\n\nFor more details check out the [live query repository](https://github.com/n1ru4l/graphql-live-query) or the [introduction blog post](https://the-guild.dev/blog/subscriptions-and-live-queries-real-time-with-graphql).\n\n[There is also a full schema example available.](https://github.com/n1ru4l/graphql-live-query/blob/main/packages/todo-example/server-ws/src/schema.ts)\n","readmeFilename":"README.md","gitHead":"0d788492f6c608d1dc5d95750907e3021107c3ef","description":"The easiest way of adding live queries to your GraphQL server!","bugs":{"url":"https://github.com/dotansimha/envelop/issues"},"homepage":"https://github.com/dotansimha/envelop#readme","_id":"@envelop/live-query@3.0.1-alpha-0d78849.0","_nodeVersion":"17.6.0","_npmVersion":"8.5.1","dist":{"integrity":"sha512-f/yMyuTHHa6fXyYJ57NVvIg0fKyzJs7gYRpwlhDXKXfgXyJdPCIChrPoicxbVrJpyM9PXvvCv+G9w4Csp5WkcA==","shasum":"228fff1c4c082de6125b4ddb36d11c75b43d1359","tarball":"http://registry-npm.ywwl.com/@envelop/live-query/download/@envelop/live-query-3.0.1-alpha-0d78849.0.tgz","fileCount":5,"unpackedSize":10202,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiH2z6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoYog//VwreEbL2RzGGg/rqeYdB2TFFgtJ7sM/1xOELh96lpNNLPZRx\r\nVssKwO8rcwkXuHLYG/Oqrb3UlB/o7BZkcXid7h79aFTKn7zwoqY+swBrshV0\r\ne1EvZVXWnAjfUkjjaCkpgSgN5m/m5L7QV18GBI0WqtJunIF3u9cK6J2cMjjo\r\nnsNQo1ggUUE9GSTMbgXuSFa8VL/0Cefu1Yl8FLfH/19s8jeCRycyMo65+j1S\r\nPOZ1gq7oSyevwmHynYy6xSgmZIAHWFPJ1J4S1slzaAkN+9kT9s2yFJOlpBdi\r\nmuGHswAemEYVC9Khj3B7MB9hvaE0TE352DeO6XqKJ37H5Vg3uChhscbGDkal\r\nEapGzc5ScEMlvGgvzk4Xn4FF9h54gKwB0crUVaPAjy06UspY7DpODD420Bcu\r\nfEfBCQ+m10sXaUcGVQ1LxOD+rkiYGgiezkqBbrewYGBOhv++zbo0HZ+GptH6\r\nvyPyqlLVevq+0Zy9qLQukzOGxRoU6g+aETQudSd8n026d3eXJLdgPCKZa9oQ\r\nWGWXly6/Fjap4L/UYPCvEpttUzSd8Dx+J8t/gOoJtSEJcGxq/8kQffrWsEpx\r\nRQrRNvpuHLnlSYUgc+mcuSERdVX5ArSCoR5LKYuQF3s6QPnQX/08On82arVL\r\nie3+cu0nmTS9J8KgTUVFRY+kLyqyNPqn+FU=\r\n=Y7uE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdw6Kk1sqV+WPgrXQa37g+S9g4uNqUuWvy/w2+SCY56wIgBz0Wr8BxknF9GJbjhXoIyNZeo6tXFznk0ULYu95hyCU="}],"size":2736,"noattachment":false,"key":"/@envelop/live-query/-/@envelop/live-query-3.0.1-alpha-0d78849.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/live-query_3.0.1-alpha-0d78849.0_1646226681974_0.25359850502703374"},"_hasShrinkwrap":false,"publish_time":1646226682128,"_cnpm_publish_time":1646226682128,"dist-tags":{"alpha":"7.0.0-alpha-20231016001432-c05b6f10","latest":"7.0.0","rc":"7.0.0-rc-20231016080110-7628eb2d"}}