mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 17:18:23 +00:00
Detect missing DocumentNode in Apollo Server (#2979)
This commit is contained in:
parent
951322cdef
commit
fa18b0a36b
2 changed files with 24 additions and 1 deletions
5
.changeset/fair-beds-beg.md
Normal file
5
.changeset/fair-beds-beg.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@graphql-hive/client': patch
|
||||
---
|
||||
|
||||
Detect missing DocumentNode in Apollo Server
|
||||
|
|
@ -176,6 +176,15 @@ export function hiveApollo(clientOrOptions: HiveClient | HivePluginOptions): Apo
|
|||
if (isLegacyV3) {
|
||||
return Promise.resolve({
|
||||
async willSendResponse(ctx) {
|
||||
if (!ctx.document) {
|
||||
const details = ctx.operationName ? `operationName: ${ctx.operationName}` : '';
|
||||
complete(args, {
|
||||
action: 'abort',
|
||||
reason: 'Document is not available' + (details ? ` (${details})` : ''),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
doc = ctx.document!;
|
||||
complete(args, ctx.response as any);
|
||||
},
|
||||
|
|
@ -185,7 +194,16 @@ export function hiveApollo(clientOrOptions: HiveClient | HivePluginOptions): Apo
|
|||
// v4
|
||||
return Promise.resolve({
|
||||
async willSendResponse(ctx) {
|
||||
doc = ctx.document!;
|
||||
if (!ctx.document) {
|
||||
const details = ctx.operationName ? `operationName: ${ctx.operationName}` : '';
|
||||
complete(args, {
|
||||
action: 'abort',
|
||||
reason: 'Document is not available' + (details ? ` (${details})` : ''),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
doc = ctx.document;
|
||||
if (ctx.response.body.kind === 'incremental') {
|
||||
complete(args, {
|
||||
action: 'abort',
|
||||
|
|
|
|||
Loading…
Reference in a new issue