Skip to content

Commit 3c66b79

Browse files
authored
fix: Trigger NoLiveMixedWithDeferStreamRule only if query has @LiVe directive
Some queries with fragments marked with @defer would trigger this error without actually having @LiVe directive in the query
1 parent 52cd5a9 commit 3c66b79

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/graphql-live-query/src/rules/NoLiveMixedWithDeferStreamRule.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ import { getLiveDirectiveNode } from "../getLiveDirectiveNode.js";
44
import { isNone } from "../Maybe.js";
55

66
export const NoLiveMixedWithDeferStreamRule: ValidationRule = (context) => {
7+
let opmatch = false;
78
return {
89
OperationDefinition(operationDefinitionNode) {
910
if (isNone(getLiveDirectiveNode(operationDefinitionNode))) {
1011
return false;
12+
} else {
13+
opmatch = true;
1114
}
1215
},
1316
Directive(directiveNode) {
1417
if (
15-
directiveNode.name.value === "defer" ||
16-
directiveNode.name.value === "stream"
18+
opmatch && (
19+
directiveNode.name.value === "defer" ||
20+
directiveNode.name.value === "stream"
21+
)
1722
) {
1823
context.reportError(
1924
new GraphQLError(

0 commit comments

Comments
 (0)