UNPKG

@n1ru4l/graphql-live-query

Version:

[![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/

19 lines (18 loc) 719 B
import { GraphQLError } from "graphql"; import { getLiveDirectiveNode } from "../getLiveDirectiveNode.js"; import { isNone } from "../Maybe.js"; export const NoLiveMixedWithDeferStreamRule = (context) => { return { OperationDefinition(operationDefinitionNode) { if (isNone(getLiveDirectiveNode(operationDefinitionNode))) { return false; } }, Directive(directiveNode) { if (directiveNode.name.value === "defer" || directiveNode.name.value === "stream") { context.reportError(new GraphQLError(`Cannot mix "@${directiveNode.name.value}" with "@live".`, directiveNode.name)); } }, }; };