Skip to content

Commit

Permalink
Re-implement #2659 in another way.
Browse files Browse the repository at this point in the history
The work in #2659 was meant to ensure that the `document` and
`operationName` were set at the appropriate locations within the lifecycle
events for the `graphql-extensions` module.

The change in #2659 introduced a new life-cycle method, but we could also
calculate this information without adding to the API surface area using data
which was already exposed to the extensions API.

Even though `graphql-extensions` is no longer really being supported,
avoiding growth on the API surface area of `graphql-extensions` is still
important for any API.

Ref: #2659
  • Loading branch information
abernix committed May 22, 2019
1 parent f8cdf59 commit 192a505
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/apollo-engine-reporting/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,15 @@ export class EngineReportingExtension<TContext = any>
this.trace.fullQueryCacheHit = !!o.requestContext.metrics
.responseCacheHit;

const operationName = this.operationName || '';
const operationName =
this.operationName || o.requestContext.operationName || '';
const documentAST = this.documentAST || o.requestContext.document;

let signature;
if (this.documentAST) {
if (documentAST) {
const calculateSignature =
this.options.calculateSignature || defaultEngineReportingSignature;
signature = calculateSignature(this.documentAST, operationName);
signature = calculateSignature(documentAST, operationName);
} else if (this.queryString) {
// We didn't get an AST, possibly because of a parse failure. Let's just
// use the full query string.
Expand Down

0 comments on commit 192a505

Please sign in to comment.