Skip to content

Commit

Permalink
Merge pull request #281 from Davide-Gheri/nestjs-graphql-v9
Browse files Browse the repository at this point in the history
Nestjs graphql v9
  • Loading branch information
Davide-Gheri committed Nov 5, 2021
2 parents 1b66c1e + 195171d commit 635ae0c
Show file tree
Hide file tree
Showing 7 changed files with 685 additions and 286 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Cache node_modules
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Lint
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/faderation-factory.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ function addTypeNameToResult(result, typename) {
export function transformFederatedSchema(schema: GraphQLSchema) {
// FIXME remove this dependency
// but graphql#printSchema does not print necessary federation directives
const { printSchema } = loadPackage(
'@apollo/federation',
const { printSubgraphSchema } = loadPackage(
'@apollo/subgraph',
'FederationFactory',
() => require('@apollo/federation'),
() => require('@apollo/subgraph'),
);

// Workaround for https://github.com/mercurius-js/mercurius/issues/273
const schemaString = printSchema(schema)
const schemaString = printSubgraphSchema(schema)
.replace('type Query {', 'type Query @extends {')
.replace('type Mutation {', 'type Mutation @extends {')
.replace('type Subscription {', 'type Subscription @extends {');
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/merge-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isFunction } from '@nestjs/common/utils/shared.utils';

// TODO better define this
const defaultOptions: MercuriusModuleOptions = {
graphiql: 'playground',
graphiql: true,
routes: true,
path: '/graphql',
fieldResolverEnhancers: [],
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
"postpublish": "pinst --enable"
},
"devDependencies": {
"@apollo/federation": "^0.26.0",
"@apollo/gateway": "^0.42.3",
"@apollo/subgraph": "^0.1.2",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-angular": "^12.1.4",
"@graphql-tools/utils": "^7.10.0",
"@nestjs/common": "^8.0.4",
"@nestjs/core": "^8.0.4",
"@nestjs/graphql": "^8.0.2",
"@nestjs/graphql": "^9.1.1",
"@nestjs/platform-fastify": "^8.0.4",
"@nestjs/testing": "^8.0.4",
"@release-it/conventional-changelog": "^3.0.1",
Expand All @@ -37,18 +38,18 @@
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.33.0",
"altair-fastify-plugin": "^4.0.7",
"apollo-server-core": "^2.21.1",
"altair-fastify-plugin": "^4.1.0",
"apollo-server-core": "^3.0.0",
"class-validator": "^0.13.1",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.23.4",
"fastify": "^3.19.1",
"fastify": "^3.22.1",
"graphql": "^15.5.1",
"graphql-scalars": "^1.10.0",
"husky": "^7.0.1",
"lint-staged": "^11.1.0",
"mercurius": "^8.0.0",
"mercurius": "^8.8.0",
"mercurius-integration-testing": "^3.2.0",
"mercurius-upload": "^2.0.0",
"pinst": "^2.1.6",
Expand All @@ -61,23 +62,22 @@
"ts-node": "^9.1.1",
"typescript": "^4.3.5",
"uvu": "^0.5.1",
"ws": "^7.5.3"
"ws": "^8.2.2"
},
"peerDependencies": {
"@apollo/federation": "^0.26.0",
"@nestjs/graphql": "~8.0.2",
"@apollo/subgraph": "~0.1.2",
"@nestjs/common": "^8.0.4",
"@nestjs/core": "^8.0.4",
"@nestjs/platform-fastify": "^8.0.4",
"altair-fastify-plugin": "4.0.7",
"fastify": "^3.19.1",
"@nestjs/graphql": "~9.1.1 | ^8.0.2",
"altair-fastify-plugin": "^4.1.0",
"apollo-server-core": "^3.0.0",
"graphql": "^15.5.1",
"mercurius": "^8.0.0",
"mercurius": "^8.8.0",
"mercurius-upload": "^2.0.0",
"reflect-metadata": "^0.1.13"
},
"peerDependenciesMeta": {
"@apollo/federation": {
"@apollo/subgraph": {
"optional": true
},
"altair-fastify-plugin": {
Expand Down
2 changes: 1 addition & 1 deletion tests/federation/gateway.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import mercurius from 'mercurius';
const gateway = Fastify();

gateway.register(mercurius, {
graphiql: 'playground',
graphiql: true,
subscription: true,
logLevel: 'trace',
gateway: {
Expand Down
2 changes: 1 addition & 1 deletion tests/federation/gateway/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MercuriusGatewayModule } from '../../../lib';
imports: [
MercuriusGatewayModule.forRootAsync({
useFactory: () => ({
graphiql: 'playground',
graphiql: true,
subscription: true,
gateway: {
services: [
Expand Down
Loading

0 comments on commit 635ae0c

Please sign in to comment.