{"name":"@n1ru4l/graphql-live-query","version":"0.11.0","peerDependencies":{"graphql":"^15.4.0 || ^16.0.0"},"repository":{"type":"git","url":"git+https://github.com/n1ru4l/graphql-live-query.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"},"gitHead":"fe27595dc6208f07daa36324301e0c964d8f487e","_id":"@n1ru4l/graphql-live-query@0.11.0","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-query/issues"},"_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-rFvmverxiyKYJpCAwbXYz36ghi938gxTGv1uOXS+2YU3Q/pOHuNxBDQU0K0fcq2tVqJxyGGGThQsIAdMZ6Xs4w==","shasum":"0d11c2a835086f18da3fddfb683f0e082a28beb6","tarball":"http://registry-npm.ywwl.com/@n1ru4l/graphql-live-query/download/@n1ru4l/graphql-live-query-0.11.0.tgz","fileCount":27,"unpackedSize":15050,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@n1ru4l%2fgraphql-live-query@0.11.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEt0qmga6odHBfHAZtlMU0YcT9DpgCv09iLapXA0wLo6AiAQ24MoJHVtkZHF6KdyKTQlxpmB6d3+djkBmp9sJtDTTQ=="}],"size":3893,"noattachment":false,"key":"/@n1ru4l/graphql-live-query/-/@n1ru4l/graphql-live-query-0.11.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:38fb4df0-639c-4f46-b467-aac9b82ed38e"}},"directories":{},"maintainers":[{"name":"n1ru4l","email":"laurinquast@googlemail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/graphql-live-query_0.11.0_1784556754847_0.8035285882351324"},"_hasShrinkwrap":false,"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","publish_time":1784556755092,"_cnpm_publish_time":1784556755092,"dist-tags":{"alpha":"0.11.0-alpha-20260720125639-14552d533a10d99fe5ade90b08c0facfad626bfe","latest":"0.11.0","rc":"0.11.0-rc-20260720130219-41f090c3809f65d64117b705343943e437843cda"}}