Skip to content

Commit f019c05

Browse files
committed
Pass the operationName to defaultOperationRegistrySignature.
Start passing the `operationName` to `defaultOperationRegistrySignature`. apollographql/apollo-tooling#1115 If `operationName` is `null`, then the operation is anonymous. However, it's not possible to register anonymous operations from the `apollo` CLI. We could fail early, however, we still want to abide by the desires of `forbidUnregisteredOperations`, so we'll allow this hash be generated anyway. The hash cannot be in the manifest, so this would be okay and allow this code to remain less conditional-y, eventually forbidding the operation when the has is not found and `forbidUnregisteredOperations` is on.
1 parent 6adc350 commit f019c05

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/apollo-server-plugin-operation-registry/src/ApolloServerPluginOperationRegistry.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,21 @@ export default function plugin(options: Options = Object.create(null)) {
105105
}
106106

107107
const hash = operationHash(
108-
defaultOperationRegistrySignature(document),
108+
defaultOperationRegistrySignature(
109+
document,
110+
111+
// XXX The `operationName` is set from the AST, not from the
112+
// request `operationName`. If `operationName` is `null`,
113+
// then the operation is anonymous. However, it's not possible
114+
// to register anonymous operations from the `apollo` CLI.
115+
// We could fail early, however, we still want to abide by the
116+
// desires of `forbidUnregisteredOperations`, so we'll allow
117+
// this hash be generated anyway. The hash cannot be in the
118+
// manifest, so this would be okay and allow this code to remain
119+
// less conditional-y, eventually forbidding the operation when
120+
// the has is not found and `forbidUnregisteredOperations` is on.
121+
requestContext.operationName || '',
122+
),
109123
);
110124

111125
// If the document itself was missing and we didn't receive a

0 commit comments

Comments
 (0)