{"name":"@n1ru4l/graphql-live-query","version":"0.10.1-alpha-20220809152435-afca7b0","peerDependencies":{"graphql":"^15.4.0 || ^16.0.0"},"repository":{"type":"git","url":"git+https://github.com/n1ru4l/graphql-live-queries.git","directory":"packages/graphql-live-query"},"homepage":"https://github.com/n1ru4l/graphql-live-queries#readme","keywords":["graphql","query","live","real-time"],"author":{"name":"n1ru4l","email":"laurinquast@googlemail.com"},"license":"MIT","main":"cjs/index.js","module":"esm/index.js","typings":"typings/index.d.ts","typescript":{"definition":"typings/index.d.ts"},"type":"module","exports":{".":{"require":{"types":"./typings/index.d.ts","default":"./cjs/index.js"},"import":{"types":"./typings/index.d.ts","default":"./esm/index.js"},"default":{"types":"./typings/index.d.ts","default":"./esm/index.js"}},"./package.json":"./package.json"},"readme":"# @n1ru4l/graphql-live-query\n\n[![npm version](https://img.shields.io/npm/v/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/graphql-live-query) [![npm downloads](https://img.shields.io/npm/dm/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/graphql-live-query)\n\nPrimitives for adding GraphQL live query operation support to any GraphQL server.\n\nFor a usage of those utility functions check out `InMemoryLiveQueryStore`(https://github.com/n1ru4l/graphql-live-queries/tree/main/packages/in-memory-live-query-store/src/InMemoryLiveQueryStore.ts).\n\n## Install Instructions\n\n```bash\nyarn add -E @n1ru4l/graphql-live-query\n```\n\n## API\n\n### `GraphQLLiveDirective`\n\nAdd the `@live` directive to your schema.\n\n```ts\nimport { GraphQLSchema, specifiedDirectives } from \"graphql\";\nimport { GraphQLLiveDirective } from \"@n1ru4l/graphql-live-query\";\nimport { query, mutation, subscription } from \"./schema\";\n\nconst schema = new GraphQLSchema({\n  query,\n  mutation,\n  subscription,\n  directives: [\n    GraphQLLiveDirective,\n    /* Keep @defer/@stream/@if/@skip */ ...specifiedDirectives,\n  ],\n});\n```\n\n**Note:** If you are using a SDL first approach for defining your schema (such as advocated by `makeExecutableSchema`) you must add the directly to your type-definitions. In order to be as up to date as possible we recommend using `graphql-tools/utils` `astFromDirective` together with `print` exported from `graphql` for generating the SDL from `GraphQLLiveDirective`.\n\n**Example ([on CodeSandbox](https://codesandbox.io/s/graphqllivedirective-usage-with-makeexecutableschema-xv2q5?file=/src/schema.ts:376-483)\n):**\n\n```ts\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { astFromDirective } from \"@graphql-tools/utils\";\nimport { GraphQLLiveDirective } from \"@n1ru4l/graphql-live-query\";\nimport { print, GraphQLSchema } from \"graphql\";\n\nconst typeDefinitions = /* GraphQL */ `\n  type Query {\n    ping: Boolean\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    ping: () => true\n  }\n};\n\nconst liveDirectiveTypeDefs = print(\n  astFromDirective(GraphQLLiveDirective)\n);\n\nexport const schema = makeExecutableSchema({\n  typeDefs: [typeDefinitions, liveDirectiveTypeDefs],\n  resolvers\n});\n```\n\n### `isLiveQueryOperationDefinitionNode`\n\nDetermine whether a `DefinitionNode` is a `LiveQueryOperationDefinitionNode`.\n\n```ts\nimport { parse, getOperationAST } from \"graphql\";\nimport { isLiveQueryOperationDefinitionNode } from \"@n1ru4l/graphql-live-query\";\n\nconst liveQueryOperationDefinitionNode = getOperationAST(\n  parse(/* GraphQL */ `\n    query @live {\n      me {\n        id\n        login\n      }\n    }\n  `)\n);\n\nisLiveQueryOperationDefinitionNode(liveQueryOperationDefinitionNode); // true\n\nconst queryOperationDefinitionNode = getOperationAST(\n  parse(/* GraphQL */ `\n    query {\n      me {\n        id\n        login\n      }\n    }\n  `)\n);\n\nisLiveQueryOperationDefinitionNode(queryOperationDefinitionNode); // false\n\nconst conditionalLiveQueryDefinitionNode = getOperationAST(\n  parse(/* GraphQL */ `\n    query($isClient: Boolean = false) @live(if: $isClient) {\n      me {\n        id\n        login\n      }\n    }\n  `)\n);\n\nisLiveQueryOperationDefinitionNode(conditionalLiveQueryDefinitionNode); // false\nisLiveQueryOperationDefinitionNode(\n  conditionalLiveQueryDefinitionNode,\n  /* variables */ {\n    isClient: false,\n  }\n); // false\nisLiveQueryOperationDefinitionNode(\n  conditionalLiveQueryDefinitionNode,\n  /* variables */ {\n    isClient: true,\n  }\n); // true\n```\n\n### `NoLiveMixedWithDeferStreamRule`\n\nValidation rule for raising a GraphQLError for a operation that use `@live` mixed with `@defer` and `@stream`.\n\n```ts\nimport { parse, validate, specifiedRules } from \"graphql\";\nimport { NoLiveMixedWithDeferStreamRule } from \"@n1ru4l/graphql-live-query\";\nimport schema from \"./schema\";\n\nconst document = parse(/* GraphQL */ `\n  query @live {\n    users @stream {\n      id\n      login\n    }\n  }\n`);\n\nconst [error] = validate(schema, document, [\n  /* default validation rules */ ...specifiedRules,\n  NoLiveMixedWithDeferStreamRule,\n]);\n\nconsole.log(error); // [GraphQLError: Cannot mix \"@stream\" with \"@live\".]\n```\n","readmeFilename":"README.md","gitHead":"afca7b0c2a976e42df00337e724bf54b489fccd1","description":"[![npm version](https://img.shields.io/npm/v/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/graphql-live-query) [![npm downloads](https://img.shields.io/npm/dm/@n1ru4l/graphql-live-query.svg)](https://www.npmjs.com/package/@n1ru4l/","bugs":{"url":"https://github.com/n1ru4l/graphql-live-queries/issues"},"_id":"@n1ru4l/graphql-live-query@0.10.1-alpha-20220809152435-afca7b0","_nodeVersion":"18.7.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-xLIcVaIpon685eaDrA6MiLjaP48hjFaQ7JZkWUhchiT+8wI5aqZQZTa8FyNzSvTSYhWTQ8kVKCGWNhQkYoIOPQ==","shasum":"f610f287f196aef9b685094fe2850172e187315f","tarball":"http://registry-npm.ywwl.com/@n1ru4l/graphql-live-query/download/@n1ru4l/graphql-live-query-0.10.1-alpha-20220809152435-afca7b0.tgz","fileCount":27,"unpackedSize":15085,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWoe6q02J2Sy1vP0Idt7kqa4Zo0ZtLo1R5yV3TF/FuSgIgVNySlYryFCdNP/w84REye5Cxsp+bNyn2m86Fs1dy4DQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi8nw/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo7tA/6AiJTh8dkb1gkirIJzTo4dliaxNkSByEJkAgaTzFYhdWUpxYv\r\nibrF6+uz9ri3ZPHHKVK8eDyFMCsutUNH7m4KxNsQt3z+RiNtvenxOEDEyT5j\r\nOp8uYCT170lv8fPpfQ3Uy7D/Rypvmx9a5xH28nxQ8jDCH7nw1MggKJRaR+Xk\r\n0npTm6MeKm7XD+Q7hfDzoaRBOwJUowHh3QKHzbrL4tx57S0TgqU2hsAZAvNL\r\nXqkTZAJyAJlmPtkBps/g3Vi4uOUzSwd3mCOb13vEo4grOBnbeRrIPrVtA9pA\r\nXjc7K156pP6hX/eEN52OgX4k6VO9P1HV9JNkBtiaQFXqhmBLdyiWnfEkaSFw\r\nVInI71++FawwAW85Pef1C+ui2BYcC3Seuv8PwLvgogDaXz6BAaZ3J0qauYyU\r\nK6NF3/HAbQToMfrepx9SYSyBOO+Gbq7kgWrDBdF/2xcDa9o8ELqEcTvQGP/s\r\nQg9gpCH+J/k2Ra7vw1HetjS6urRJ15K0+4NrZttMJ6P0wa/ADj52ESWqi9pC\r\nI0AwLArn3Kck3Dae4NeaZ8SLvTakY5TMRfbmjjpKDZTONK6p820q72lf/7YY\r\nugyTzmCFxflKpD0OZziSn7BHTE85El/O66T20ABlBOAuhQ6dDV/C2y/0Yft4\r\n0hclveJyL/MRTODqrZ4RbgB/vVAaK0dOIgA=\r\n=bfNU\r\n-----END PGP SIGNATURE-----\r\n","size":3918,"noattachment":false,"key":"/@n1ru4l/graphql-live-query/-/@n1ru4l/graphql-live-query-0.10.1-alpha-20220809152435-afca7b0.tgz"},"_npmUser":{"name":"n1ru4l","email":"laurinquast@googlemail.com"},"directories":{},"maintainers":[{"name":"n1ru4l","email":"laurinquast@googlemail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-live-query_0.10.1-alpha-20220809152435-afca7b0_1660058687134_0.9985391037241407"},"_hasShrinkwrap":false,"publish_time":1660058687294,"_cnpm_publish_time":1660058687294,"dist-tags":{"alpha":"0.11.0-alpha-20260720125639-14552d533a10d99fe5ade90b08c0facfad626bfe","latest":"0.11.0","rc":"0.11.0-rc-20260720130219-41f090c3809f65d64117b705343943e437843cda"}}