Skip to content

Commit

Permalink
__resolveReference follow-ups (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-scheer authored Apr 22, 2022
1 parent dba2207 commit 8a5338c
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 157 deletions.
5 changes: 4 additions & 1 deletion gateway-js/src/__tests__/executeQueryPlan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import { ApolloGateway } from '..';
import { ApolloServerBase as ApolloServer } from 'apollo-server-core';
import { getFederatedTestingSchema } from './execution-utils';
import { Schema, Operation, parseOperation, buildSchemaFromAST, arrayEquals } from '@apollo/federation-internals';
import { addResolversToSchema, GraphQLResolverMap } from '../schema-helper';
import {
addResolversToSchema,
GraphQLResolverMap,
} from '@apollo/subgraph/src/schema-helper';

expect.addSnapshotSerializer(astSerializer);
expect.addSnapshotSerializer(queryPlanSerializer);
Expand Down
4 changes: 2 additions & 2 deletions gateway-js/src/__tests__/execution-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
GraphQLSchemaValidationError,
GraphQLSchemaModule,
GraphQLResolverMap,
} from '../schema-helper';
GraphQLSchemaValidationError,
} from '@apollo/subgraph/src/schema-helper';
import { GraphQLRequest, GraphQLExecutionResult } from 'apollo-server-types';
import type { Logger } from '@apollo/utils.logger';
import { buildSubgraphSchema } from '@apollo/subgraph';
Expand Down
2 changes: 1 addition & 1 deletion gateway-js/src/__tests__/gateway/endToEnd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fetch, { Response } from 'node-fetch';
import { ApolloGateway } from '../..';
import { fixtures } from 'apollo-federation-integration-testsuite';
import { ApolloServerPluginInlineTrace } from 'apollo-server-core';
import { GraphQLSchemaModule } from '../../schema-helper';
import { GraphQLSchemaModule } from '@apollo/subgraph/src/schema-helper';
import { buildSchema, ObjectType, ServiceDefinition } from '@apollo/federation-internals';
import gql from 'graphql-tag';
import { printSchema } from 'graphql';
Expand Down
2 changes: 1 addition & 1 deletion gateway-js/src/__tests__/gateway/reporting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Plugin, Config, Refs } from 'pretty-format';
import { Report, Trace } from 'apollo-reporting-protobuf';
import { fixtures } from 'apollo-federation-integration-testsuite';
import { nockAfterEach, nockBeforeEach } from '../nockAssertions';
import { GraphQLSchemaModule } from '../../schema-helper';
import { GraphQLSchemaModule } from '@apollo/subgraph/src/schema-helper';
import resolvable, { Resolvable } from '@josephg/resolvable';

// Normalize specific fields that change often (eg timestamps) to static values,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LocalGraphQLDataSource } from '../LocalGraphQLDataSource';
import { buildSubgraphSchema } from '@apollo/subgraph';
import gql from 'graphql-tag';
import { GraphQLResolverMap } from '../../schema-helper';
import { GraphQLResolverMap } from '@apollo/subgraph/src/schema-helper';
import { GraphQLRequestContext } from 'apollo-server-types';
import { GraphQLDataSourceRequestKind } from '../types';

Expand Down
105 changes: 0 additions & 105 deletions gateway-js/src/schema-helper/addResolversToSchema.ts

This file was deleted.

11 changes: 0 additions & 11 deletions gateway-js/src/schema-helper/error.ts

This file was deleted.

3 changes: 0 additions & 3 deletions gateway-js/src/schema-helper/index.ts

This file was deleted.

23 changes: 0 additions & 23 deletions gateway-js/src/schema-helper/resolverMap.ts

This file was deleted.

18 changes: 9 additions & 9 deletions subgraph-js/src/schema-helper/buildSchemaFromSDL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ export function addResolversToSchema(

if (isAbstractType(type)) {
for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
if (fieldName === "__resolveReference") {
if (fieldName === '__resolveReference') {
type.extensions = {
...type.extensions,
apollo: {
...type.extensions.apollo,
subgraph: {
...type.extensions.apollo?.subgraph,
resolveReference: fieldConfig,
}
},
},
};
} else if (fieldName.startsWith("__")) {
(type as any)[fieldName.substring(2)] = fieldConfig;
} else if (fieldName === '__resolveType') {
type.resolveType = fieldConfig;
}
}
}
Expand Down Expand Up @@ -163,21 +163,21 @@ export function addResolversToSchema(
if (!isObjectType(type)) continue;

const fieldMap = type.getFields();

for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) {
if (fieldName === "__resolveReference") {
if (fieldName === '__resolveReference') {
type.extensions = {
...type.extensions,
apollo: {
...type.extensions.apollo,
subgraph: {
...type.extensions.apollo?.subgraph,
resolveReference: fieldConfig,
}
},
},
};
} else if (fieldName.startsWith("__")) {
(type as any)[fieldName.substring(2)] = fieldConfig;
continue;
} else if (fieldName === '__isTypeOf') {
type.isTypeOf = fieldConfig;
continue;
}

Expand Down

0 comments on commit 8a5338c

Please sign in to comment.