Skip to content

Commit

Permalink
Merge branch 'master' of github.com:thiagomini/nest-graphql into test…
Browse files Browse the repository at this point in the history
…/function-utils
  • Loading branch information
thiagomini committed Oct 25, 2022
2 parents 2ae15c9 + 359c16a commit acc261e
Show file tree
Hide file tree
Showing 114 changed files with 6,184 additions and 3,104 deletions.
15 changes: 10 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
build:
working_directory: ~/nest
docker:
- image: circleci/node:16
- image: cimg/node:16.18
steps:
- checkout
- *restore-cache
Expand All @@ -38,14 +38,20 @@ jobs:
e2e_tests:
working_directory: ~/nest
docker:
- image: circleci/node:16
- image: cimg/node:16.18
steps:
- checkout
- *restore-cache
- *install-deps
- run:
name: E2E tests
command: yarn test:e2e
name: E2E tests (graphql)
command: yarn test:e2e:graphql
- run:
name: E2E tests (apollo)
command: yarn test:e2e:apollo
- run:
name: E2E tests (mercurius)
command: yarn test:e2e:mercurius

workflows:
version: 2
Expand All @@ -55,4 +61,3 @@ workflows:
- e2e_tests:
requires:
- build

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ body:
required: true
attributes:
label: "Expected behavior"
description: "A clear and concise description of what you expected to happend (or code)"
description: "A clear and concise description of what you expected to happen (or code)"

- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ body:
required: true
attributes:
label: "Expected behavior"
description: "A clear and concise description of what you expected to happend (or code)"
description: "A clear and concise description of what you expected to happen (or code)"

- type: textarea
attributes:
Expand Down
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
packages/**/tests/generated-definitions/*.ts
packages/**/tests/**/*.fixture.ts
packages/**/tests/**/*.fixture.ts

packages/**/tests/cases/**/*.ts
packages/**/tests/cases/**/*.ts
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) Kamil Mysliwiec
Copyright (c) 2017-2022 Kamil Mysliwiec

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "10.0.15",
"version": "10.1.4",
"npmClient": "yarn",
"useWorkspaces": true,
"changelog": {
Expand Down
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,47 @@
"publish:next": "lerna publish --dist-tag next",
"test:e2e": "lerna run test:e2e --parallel",
"test:e2e:dev": "lerna run test:e2e:dev --parallel",
"test:e2e:apollo": "lerna run test:e2e --scope @nestjs/apollo --stream",
"test:e2e:graphql": "lerna run test:e2e --scope @nestjs/graphql --stream",
"test:e2e:mercurius": "lerna run test:e2e --scope @nestjs/mercurius --stream",
"prepare": "husky install"
},
"resolutions": {
"graphql": "15.8.0"
},
"devDependencies": {
"@commitlint/cli": "17.0.2",
"@commitlint/config-angular": "17.0.0",
"@commitlint/cli": "17.1.2",
"@commitlint/config-angular": "17.1.0",
"@types/graphql": "14.5.0",
"@types/jest": "28.1.0",
"@types/node": "17.0.0",
"@types/jest": "29.2.0",
"@types/node": "18.11.5",
"@types/node-fetch": "3.0.3",
"@types/normalize-path": "3.0.0",
"@types/ws": "8.5.3",
"@typescript-eslint/eslint-plugin": "5.27.0",
"@typescript-eslint/parser": "5.27.0",
"@typescript-eslint/eslint-plugin": "5.41.0",
"@typescript-eslint/parser": "5.41.0",
"class-transformer": "0.5.1",
"class-validator": "0.13.2",
"eslint": "8.16.0",
"eslint": "8.26.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-prettier": "4.2.1",
"graphql": "15.8.0",
"graphql-subscriptions": "2.0.0",
"husky": "8.0.1",
"jest": "28.1.0",
"lerna": "5.0.0",
"jest": "29.2.2",
"lerna": "6.0.1",
"lerna-changelog": "2.2.0",
"lint-staged": "13.0.0",
"prettier": "2.6.2",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"reflect-metadata": "0.1.13",
"release-it": "15.0.0",
"release-it": "15.5.0",
"rimraf": "3.0.2",
"rxjs": "7.5.5",
"supertest": "6.2.3",
"ts-jest": "28.0.3",
"ts-node": "10.8.0",
"typescript": "4.7.2"
"rxjs": "7.5.7",
"supertest": "6.3.1",
"ts-jest": "29.0.3",
"ts-node": "10.9.1",
"typescript": "4.8.4"
},
"changelog": {
"labels": {
Expand Down
35 changes: 20 additions & 15 deletions packages/apollo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/apollo",
"version": "10.0.14",
"version": "10.1.4",
"description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
"author": "Kamil Mysliwiec",
"license": "MIT",
Expand All @@ -15,26 +15,30 @@
"url": "git+https://github.com/nestjs/graphql.git"
},
"scripts": {
"test:e2e": "jest --config ./tests/jest-e2e.ts --runInBand",
"test:e2e": "jest --config ./tests/jest-e2e.ts --runInBand && yarn test:e2e:fed2",
"test:e2e:fed2": "jest --config ./tests/jest-e2e-fed2.ts --runInBand",
"test:e2e:dev": "jest --config ./tests/jest-e2e.ts --runInBand --watch"
},
"bugs": {
"url": "https://github.com/nestjs/graphql/issues"
},
"devDependencies": {
"@apollo/gateway": "0.51.0",
"@nestjs/common": "8.4.6",
"@nestjs/core": "8.4.6",
"@nestjs/platform-express": "8.4.6",
"@nestjs/platform-fastify": "8.4.6",
"@nestjs/testing": "8.4.6",
"@apollo/gateway": "0.52.1",
"@apollo/gateway-v2": "npm:@apollo/gateway@2.1.4",
"@apollo/subgraph-v2": "npm:@apollo/subgraph@2.1.4",
"@nestjs/common": "8.4.7",
"@nestjs/core": "8.4.7",
"@nestjs/platform-express": "8.4.7",
"@nestjs/platform-fastify": "8.4.7",
"@nestjs/testing": "8.4.7",
"apollo-cache-inmemory": "1.6.6",
"apollo-client": "2.6.10",
"apollo-link-ws": "1.0.20",
"apollo-server-core": "3.8.1",
"apollo-server-express": "3.8.1",
"apollo-server-fastify": "3.8.1",
"apollo-server-plugin-response-cache": "3.6.0"
"apollo-server-core": "3.10.3",
"apollo-server-express": "3.10.3",
"apollo-server-fastify": "3.10.3",
"apollo-server-plugin-response-cache": "3.7.1",
"graphql-16": "npm:graphql@16.6.0"
},
"dependencies": {
"iterall": "1.3.0",
Expand All @@ -43,12 +47,13 @@
},
"peerDependencies": {
"@apollo/gateway": "^0.44.1 || ^0.46.0 || ^0.48.0 || ^0.49.0 || ^0.50.0 || ^2.0.0",
"@nestjs/common": "^8.2.3",
"@nestjs/core": "^8.2.3",
"@nestjs/common": "^8.2.3 || ^9.0.0",
"@nestjs/core": "^8.2.3 || ^9.0.0",
"@nestjs/graphql": "^10.0.0",
"apollo-server-core": "^3.5.0",
"apollo-server-express": "^3.5.0",
"apollo-server-fastify": "^3.5.0"
"apollo-server-fastify": "^3.5.0",
"graphql": "^15.8.0 || ^16.0.0"
},
"peerDependenciesMeta": {
"@apollo/gateway": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { IntrospectAndCompose } from '@apollo/gateway-v2';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloGatewayDriver, ApolloGatewayDriverConfig } from '../../../lib';

@Module({
imports: [
GraphQLModule.forRoot<ApolloGatewayDriverConfig>({
driver: ApolloGatewayDriver,
gateway: {
debug: false,
supergraphSdl: new IntrospectAndCompose({
subgraphs: [
{ name: 'users', url: 'http://localhost:3001/graphql' },
{ name: 'posts', url: 'http://localhost:3002/graphql' },
],
}),
},
}),
],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloServerPluginInlineTraceDisabled } from 'apollo-server-core';
import { ApolloDriverConfig } from '../../../lib';
import { ApolloFederationDriver } from '../../../lib/drivers';
import { PostsModule } from './posts/posts.module';
import { User } from './posts/user.entity';

@Module({
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloFederationDriver,
autoSchemaFile: {
federation: 2,
},
buildSchemaOptions: {
orphanedTypes: [User],
},
plugins: [ApolloServerPluginInlineTraceDisabled()],
}),
PostsModule,
],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { registerEnumType } from '@nestjs/graphql';

export enum PostType {
IMAGE = 'IMAGE',
TEXT = 'TEXT',
}

registerEnumType(PostType, {
name: 'PostType',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Directive, Field, ID, ObjectType } from '@nestjs/graphql';
import { PostType } from './post-type.enum';

@ObjectType()
@Directive('@key(fields: "id")')
export class Post {
@Field(() => ID)
id: string;

@Field()
title: string;

@Field()
body: string;

userId: string;

@Field({ nullable: true })
publishDate: Date;

@Field(() => PostType, { nullable: true })
type: PostType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { PostsResolvers } from './posts.resolvers';
import { UsersResolvers } from './users.resolvers';
import { PostsService } from './posts.service';

@Module({
providers: [PostsResolvers, PostsService, UsersResolvers],
})
export class PostsModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
Args,
ID,
Mutation,
Parent,
Query,
ResolveField,
Resolver,
} from '@nestjs/graphql';
import { PostType } from './post-type.enum';
import { Post } from './posts.entity';
import { PostsService } from './posts.service';
import { User } from './user.entity';

@Resolver(Post)
export class PostsResolvers {
constructor(private readonly postsService: PostsService) {}

@Query(() => [Post])
getPosts(
@Args('type', { nullable: true, type: () => PostType }) type: PostType,
) {
if (type) {
return this.postsService.findByType(type);
} else {
return this.postsService.findAll();
}
}

@Mutation(() => Post)
publishPost(
@Args('id', { type: () => ID }) id,
@Args('publishDate') publishDate: Date,
) {
return this.postsService.publish(id, publishDate);
}

@ResolveField('user', () => User, { nullable: true })
getUser(@Parent() post: Post) {
return { __typename: 'User', id: post.userId };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Injectable } from '@nestjs/common';
import { Post } from './posts.entity';
import { PostType } from './post-type.enum';

@Injectable()
export class PostsService {
private readonly posts: Post[] = [
{
id: '1',
title: 'HELLO WORLD',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
userId: '5',
publishDate: new Date(0),
type: PostType.TEXT,
},
];

findAll() {
return Promise.resolve(this.posts);
}

findById(id: string) {
return Promise.resolve(this.posts.find((p) => p.id === id));
}

findByUserId(id: string) {
return Promise.resolve(this.posts.filter((p) => p.userId === id));
}

findByType(type: PostType) {
return Promise.resolve(this.posts.filter((p) => p.type === type));
}

async publish(id: string, publishDate: Date) {
const post = await this.findById(id);
post.publishDate = publishDate;
return post;
}
}
Loading

0 comments on commit acc261e

Please sign in to comment.