Skip to content

Commit

Permalink
fix(@nestjs/graphql) fix federated schema generated with code first a…
Browse files Browse the repository at this point in the history
…pproach

Federated schema generated with the code first approach does not contain
the directives.

Closes nestjs#1597
  • Loading branch information
keadex committed Oct 7, 2021
1 parent 89c8436 commit 458cfba
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/graphql-definitions.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { isEmpty } from '@nestjs/common/utils/shared.utils';
import { gql } from 'apollo-server-core';
import * as chokidar from 'chokidar';
import { printSchema } from 'graphql';
import { printSchema } from '@apollo/federation';
import {
DefinitionsGeneratorOptions,
GraphQLAstExplorer,
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql-schema.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { isString } from '@nestjs/common/utils/shared.utils';
import {
GraphQLSchema,
lexicographicSortSchema,
printSchema,
specifiedDirectives,
} from 'graphql';
import { printSchema } from '@apollo/federation';
import { resolve } from 'path';
import { GRAPHQL_SDL_FILE_HEADER } from './graphql.constants';
import { GqlModuleOptions } from './interfaces';
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
GraphQLSchema,
GraphQLSchemaConfig,
lexicographicSortSchema,
printSchema,
} from 'graphql';
import { printSchema } from '@apollo/federation';
import { forEach, isEmpty } from 'lodash';
import {
DefinitionsGeneratorOptions,
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { ApolloServerBase } from 'apollo-server-core';
import { printSchema } from 'graphql';
import { printSchema } from '@apollo/federation';
import { GraphQLAstExplorer } from './graphql-ast.explorer';
import { GraphQLSchemaBuilder } from './graphql-schema.builder';
import { GraphQLSchemaHost } from './graphql-schema.host';
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/code-first-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
GraphQLSchema,
IntrospectionField,
IntrospectionSchema,
printSchema,
TypeKind
} from 'graphql';
import { printSchema } from '@apollo/federation';
import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants';
import {
GraphQLSchemaBuilderModule,
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/graphql-sort-auto-schema.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { printSchema, GraphQLSchema } from 'graphql';
import { GraphQLSchema } from 'graphql';
import { printSchema } from '@apollo/federation';
import { FileSystemHelper } from '../../lib/schema-builder/helpers/file-system.helper';
import { sortedPrintedSchemaSnapshot } from '../utils/printed-schema.snapshot';
import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants';
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/graphql-sort-schema.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { printSchema, GraphQLSchema } from 'graphql';
import { GraphQLSchema } from 'graphql';
import { printSchema } from '@apollo/federation';
import { SortSchemaModule } from '../graphql/sort-schema.module';
import { GRAPHQL_SDL_FILE_HEADER } from '../../lib/graphql.constants';
import { GraphQLSchemaHost } from '../../lib';
Expand Down

0 comments on commit 458cfba

Please sign in to comment.