Skip to content

Commit

Permalink
extract and export NonFtv1ErrorPath interface
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer committed Jan 24, 2023
1 parent 0367f6a commit 52f8b64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions packages/gateway-interface/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export interface GatewayHTTPResponse {

export type GatewaySchemaHash = string & { __fauxpaque: 'SchemaHash' };

export interface NonFtv1ErrorPath {
subgraph: string;
path: GraphQLError['path'];
}

export interface GatewayGraphQLRequestMetrics {
captureTraces?: boolean;
persistedQueryHit?: boolean;
Expand All @@ -118,10 +123,7 @@ export interface GatewayGraphQLRequestMetrics {
registeredOperation?: boolean;
startHrTime?: [number, number];
queryPlanTrace?: Trace.QueryPlanNode;
nonFtv1ErrorPaths?: {
subgraph: string;
path: GraphQLError['path'];
}[];
nonFtv1ErrorPaths?: NonFtv1ErrorPath[];
}

export interface GatewayCachePolicy extends GatewayCacheHint {
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/externalTypes/requestPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
OperationDefinitionNode,
} from 'graphql';
import type { CachePolicy } from '@apollo/cache-control-types';
import type { NonFtv1ErrorPath } from '@apollo/server-gateway-interface';

This comment has been minimized.

Copy link
@glasser

glasser Jan 25, 2023

Member

just want to note that I confirmed that dependencies from server/src/externalTypes on server-gateway-interface is a thing that we do already (whereas the reverse is bad)

This comment has been minimized.

Copy link
@trevor-scheer

trevor-scheer Jan 25, 2023

Author Member

Just so I understand, you're agreeing this is the correct direction of dependency and not the other way around?

This comment has been minimized.

Copy link
@glasser

glasser Jan 25, 2023

Member

Yes


export interface GraphQLRequestMetrics {
// It would be more accurate to call this fieldLevelInstrumentation (it is
Expand All @@ -33,7 +34,7 @@ export interface GraphQLRequestMetrics {
registeredOperation?: boolean;
startHrTime?: [number, number];
queryPlanTrace?: Trace.QueryPlanNode;
nonFtv1ErrorPaths?: { subgraph: string; path: GraphQLError['path'] }[];
nonFtv1ErrorPaths?: NonFtv1ErrorPath[];
}

export interface GraphQLRequestContext<TContext extends BaseContext> {
Expand Down
7 changes: 4 additions & 3 deletions packages/server/src/plugin/usageReporting/stats.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { NonFtv1ErrorPath } from '@apollo/server-gateway-interface';
import {
type google,
type IContextualizedStats,
Expand Down Expand Up @@ -73,7 +74,7 @@ export class OurReport implements Required<IReport> {
asTrace: boolean;
referencedFieldsByType: ReferencedFieldsByType;
maxTraceBytes?: number;
nonFtv1ErrorPaths: { subgraph: string; path: GraphQLError['path'] }[];
nonFtv1ErrorPaths: NonFtv1ErrorPath[];
}) {
const tracesAndStats = this.getTracesAndStats({
statsReportKey,
Expand Down Expand Up @@ -171,7 +172,7 @@ class StatsByContext {
addTrace(
trace: Trace,
sizeEstimator: SizeEstimator,
nonFtv1ErrorPaths: { subgraph: string; path: GraphQLError['path'] }[],
nonFtv1ErrorPaths: NonFtv1ErrorPath[],
) {
this.getContextualizedStats(trace, sizeEstimator).addTrace(
trace,
Expand Down Expand Up @@ -226,7 +227,7 @@ export class OurContextualizedStats implements Required<IContextualizedStats> {
addTrace(
trace: Trace,
sizeEstimator: SizeEstimator,
nonFtv1ErrorPaths: { subgraph: string; path: GraphQLError['path'] }[] = [],
nonFtv1ErrorPaths: NonFtv1ErrorPath[] = [],
) {
const { fieldExecutionWeight } = trace;
if (!fieldExecutionWeight) {
Expand Down

0 comments on commit 52f8b64

Please sign in to comment.