Skip to content

Commit

Permalink
Merge pull request #2 from nestjs/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
roypeled committed Feb 26, 2023
2 parents 26ef9f2 + 63e3623 commit 0bf8de6
Show file tree
Hide file tree
Showing 106 changed files with 4,314 additions and 2,334 deletions.
4 changes: 2 additions & 2 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: cimg/node:16.17
- image: cimg/node:16.19
steps:
- checkout
- *restore-cache
Expand All @@ -38,7 +38,7 @@ jobs:
e2e_tests:
working_directory: ~/nest
docker:
- image: cimg/node:16.17
- image: cimg/node:16.19
steps:
- checkout
- *restore-cache
Expand Down
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.1.1",
"version": "10.2.0",
"npmClient": "yarn",
"useWorkspaces": true,
"changelog": {
Expand Down
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@
"graphql": "15.8.0"
},
"devDependencies": {
"@commitlint/cli": "17.1.2",
"@commitlint/config-angular": "17.1.0",
"@commitlint/cli": "17.4.4",
"@commitlint/config-angular": "17.4.4",
"@types/graphql": "14.5.0",
"@types/jest": "29.0.0",
"@types/node": "17.0.0",
"@types/jest": "29.4.0",
"@types/node": "18.14.1",
"@types/node-fetch": "3.0.3",
"@types/normalize-path": "3.0.0",
"@types/ws": "8.5.3",
"@typescript-eslint/eslint-plugin": "5.36.2",
"@typescript-eslint/parser": "5.36.2",
"@types/ws": "8.5.4",
"@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.53.0",
"class-transformer": "0.5.1",
"class-validator": "0.13.2",
"eslint": "8.23.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"class-validator": "0.14.0",
"eslint": "8.35.0",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-prettier": "4.2.1",
"graphql": "15.8.0",
"graphql-subscriptions": "2.0.0",
"husky": "8.0.1",
"jest": "29.0.2",
"lerna": "5.5.0",
"husky": "8.0.3",
"jest": "29.4.3",
"lerna": "6.5.1",
"lerna-changelog": "2.2.0",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"lint-staged": "13.1.2",
"prettier": "2.8.4",
"reflect-metadata": "0.1.13",
"release-it": "15.4.1",
"rimraf": "3.0.2",
"rxjs": "7.5.6",
"supertest": "6.2.4",
"ts-jest": "28.0.8",
"release-it": "15.6.0",
"rimraf": "4.1.2",
"rxjs": "7.8.0",
"supertest": "6.3.3",
"ts-jest": "29.0.5",
"ts-node": "10.9.1",
"typescript": "4.8.2"
"typescript": "4.9.5"
},
"changelog": {
"labels": {
Expand Down
44 changes: 32 additions & 12 deletions packages/apollo/lib/utils/async-iterator.util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $$asyncIterator } from 'iterall';

type AsyncIterator<T> = {
export type AsyncIterator<T> = {
next(value?: any): Promise<IteratorResult<T>>;
return(): any;
throw(error: any): any;
Expand All @@ -12,18 +12,38 @@ export const createAsyncIterator = async <T = any>(
filterFn: Function,
): Promise<AsyncIterator<T>> => {
const asyncIterator = await lazyFactory;
const getNextValue = async () => {
if (!asyncIterator || typeof asyncIterator.next !== 'function') {
return Promise.reject(asyncIterator);
}
const getNextValue = () => {
return new Promise<IteratorResult<any>>((resolve, reject) => {
const inner = () => {
if (!asyncIterator || typeof asyncIterator.next !== 'function') {
reject(asyncIterator);
return;
}

const payload = await asyncIterator.next();
if (payload.done === true) {
return payload;
}
return Promise.resolve(filterFn(payload.value))
.catch(() => false)
.then((result) => (result ? payload : getNextValue()));
asyncIterator
.next()
.then((payload) => {
if (payload.done === true) {
resolve(payload);
return;
}
Promise.resolve(filterFn(payload.value))
.catch(() => false)
.then((result) => {
if (result === true) {
resolve(payload);
return;
}

inner();
return;
});
})
.catch(reject);
};

inner();
});
};

return {
Expand Down
22 changes: 13 additions & 9 deletions packages/apollo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nestjs/apollo",
"version": "10.1.0",
"version": "10.2.0",
"description": "Nest - modern, fast, powerful node.js web framework (@apollo)",
"author": "Kamil Mysliwiec",
"license": "MIT",
Expand All @@ -23,9 +23,9 @@
"url": "https://github.com/nestjs/graphql/issues"
},
"devDependencies": {
"@apollo/gateway": "0.52.1",
"@apollo/gateway-v2": "npm:@apollo/gateway@2.1.1",
"@apollo/subgraph-v2": "npm:@apollo/subgraph@2.1.1",
"@apollo/gateway": "0.54.1",
"@apollo/gateway-v2": "npm:@apollo/gateway@2.3.2",
"@apollo/subgraph-v2": "npm:@apollo/subgraph@2.3.2",
"@nestjs/common": "8.4.7",
"@nestjs/core": "8.4.7",
"@nestjs/platform-express": "8.4.7",
Expand All @@ -34,19 +34,20 @@
"apollo-cache-inmemory": "1.6.6",
"apollo-client": "2.6.10",
"apollo-link-ws": "1.0.20",
"apollo-server-core": "3.10.2",
"apollo-server-express": "3.10.2",
"apollo-server-fastify": "3.10.2",
"apollo-server-plugin-response-cache": "3.7.0",
"apollo-server-core": "3.11.1",
"apollo-server-express": "3.11.1",
"apollo-server-fastify": "3.11.1",
"apollo-server-plugin-response-cache": "3.8.1",
"graphql-16": "npm:graphql@16.6.0"
},
"dependencies": {
"iterall": "1.3.0",
"lodash.omit": "4.5.0",
"tslib": "2.4.0"
"tslib": "2.5.0"
},
"peerDependencies": {
"@apollo/gateway": "^0.44.1 || ^0.46.0 || ^0.48.0 || ^0.49.0 || ^0.50.0 || ^2.0.0",
"@apollo/subgraph": "^2.0.0",
"@nestjs/common": "^8.2.3 || ^9.0.0",
"@nestjs/core": "^8.2.3 || ^9.0.0",
"@nestjs/graphql": "^10.0.0",
Expand All @@ -59,6 +60,9 @@
"@apollo/gateway": {
"optional": true
},
"@apollo/subgraph": {
"optional": true
},
"apollo-server-core": {
"optional": true
},
Expand Down
21 changes: 21 additions & 0 deletions packages/apollo/tests/code-first-duplicate-resolvers/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver } from '../../lib';
import { ModuleAModule } from './module-a/module-a.module';
import { ModuleBModule } from './module-b/module-b.module';
import { QueryResolver } from './query.resolver';

@Module({
imports: [
GraphQLModule.forRoot({
driver: ApolloDriver,
autoSchemaFile: true,
}),
ModuleAModule,
ModuleBModule,
QueryResolver,
],
controllers: [],
providers: [],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { UserResolver } from './user.resolver';

@Module({
imports: [],
controllers: [],
providers: [UserResolver],
})
export class ModuleAModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Args, Mutation, Resolver } from '@nestjs/graphql';

@Resolver()
export class UserResolver {
@Mutation(() => String, { name: 'moduleALogin' })
login(@Args('code') code: string) {
return code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { UserResolver } from './user.resolver';

@Module({
imports: [],
controllers: [],
providers: [UserResolver],
})
export class ModuleBModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Args, Mutation, Resolver } from '@nestjs/graphql';

@Resolver()
export class UserResolver {
@Mutation(() => String, { name: 'moduleBLogin' })
login(@Args('username') username: string) {
return username;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';

@Resolver()
export class QueryResolver {
@Query(() => Boolean, { name: '_' })
test() {
return true;
}
}
30 changes: 30 additions & 0 deletions packages/apollo/tests/code-first/other/sample-scalar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CustomScalar, Scalar } from '@nestjs/graphql';
import { Kind } from 'graphql';

@Scalar('SampleScalar')
export class SampleScalar implements CustomScalar<string, string> {
description = 'A sample scalar';

parseValue(value: unknown): string {
if (typeof value !== 'string') {
throw new Error(`Expected a string, but got ${value}.`);
}
return value;
}

serialize(obj: unknown): string {
if (typeof obj !== 'string') {
throw new Error(`Expected a string, but got ${obj}.`);
}
return obj;
}

parseLiteral(ast: any): string {
if (ast.kind === Kind.STRING) {
return ast.value;
}
throw new Error(
`Expected value of kind 'STRING', but got kind '${ast.kind}'.`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export class NewRecipeInput {
@Length(30, 255)
description?: string;

@Field({ nullable: false, defaultValue: 'published' })
status: string;

@Type(() => String)
@Field((type) => [String])
ingredients: string[];
Expand Down
7 changes: 5 additions & 2 deletions packages/apollo/tests/code-first/recipes/dto/recipes.args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { ArgsType, Field, Int } from '@nestjs/graphql';
import { Max, Min } from 'class-validator';
@ArgsType()
export class RecipesArgs {
@Field((type) => Int, { description: 'number of items to skip' })
@Field((type) => Int, {
description: 'number of items to skip',
nullable: true,
})
@Min(0)
skip: number = 0;

@Field((type) => Int)
@Field((type) => Int, { nullable: true })
@Min(1)
@Max(50)
take: number = 25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class RecipesResolver {
@Args('id', {
defaultValue: '1',
description: 'recipe id',
nullable: true,
})
id: string,
): Promise<IRecipe> {
Expand Down
20 changes: 20 additions & 0 deletions packages/apollo/tests/duplicate-resolvers/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { join } from 'path';
import { ApolloDriver } from '../../lib';
import { ModuleAModule } from './module-a/module-a.module';
import { ModuleBModule } from './module-b/module-b.module';

@Module({
imports: [
GraphQLModule.forRoot({
driver: ApolloDriver,
typePaths: [join(__dirname, '*.graphql')],
}),
ModuleAModule,
ModuleBModule,
],
controllers: [],
providers: [],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type Query {
_: Boolean
}

type Mutation {
moduleALogin(code: String): String
moduleBLogin(username: String): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { UserResolver } from './user.resolver';

@Module({
imports: [],
controllers: [],
providers: [UserResolver],
})
export class ModuleAModule {}
Loading

0 comments on commit 0bf8de6

Please sign in to comment.