Skip to content

Commit 899e30f

Browse files
Merge branch 'master' into BrunnerLivio-patch-1
2 parents a4e4ab3 + c755b28 commit 899e30f

File tree

15 files changed

+91
-17
lines changed

15 files changed

+91
-17
lines changed

content/controllers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ async create(createCatDto) {
407407
}
408408
```
409409

410+
> info **Hint** Our `ValidationPipe` can filter out properties that should not be received by the method handler. In this case, we can whitelist the acceptable properties, and any property not included in the whitelist is automatically stripped from the resulting object. In the `CreateCatDto` example, our whitelist is the `name`, `age`, and `breed` properties. Learn more [here](https://docs.nestjs.com/techniques/validation#stripping-properties).
411+
410412
#### Handling errors
411413

412414
There's a separate chapter about handling errors (i.e., working with exceptions) [here](/exception-filters).

content/discover/who-uses.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
"https://pchas.ir",
249249
"https://tayeh.ir",
250250
"https://forwardigital.co.uk",
251-
"https://rozetka.com.ua"
251+
"https://rozetka.com.ua",
252+
"https://www.itrio.net"
252253
]
253254
}

content/faq/hybrid-application.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const microservice = app.connectMicroservice({
88
transport: Transport.TCP,
99
});
1010

11-
await app.startAllMicroservicesAsync();
11+
await app.startAllMicroservices();
1212
await app.listen(3001);
1313
```
1414

@@ -31,7 +31,7 @@ const microserviceRedis = app.connectMicroservice<MicroserviceOptions>({
3131
},
3232
});
3333

34-
await app.startAllMicroservicesAsync();
34+
await app.startAllMicroservices();
3535
await app.listen(3001);
3636
```
3737

content/faq/serverless.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ return {
271271
...options,
272272
externals: [],
273273
output: {
274+
...options.output,
274275
libraryTarget: 'commonjs2',
275276
},
276277
// ... the rest of the configuration

content/graphql/complexity.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ import {
3535
export class ComplexityPlugin implements ApolloServerPlugin {
3636
constructor(private gqlSchemaHost: GraphQLSchemaHost) {}
3737

38-
requestDidStart(): GraphQLRequestListener {
38+
async requestDidStart(): Promise<GraphQLRequestListener> {
39+
const maxComplexity = 20;
3940
const { schema } = this.gqlSchemaHost;
4041

4142
return {
42-
didResolveOperation({ request, document }) {
43+
async didResolveOperation({ request, document }) {
4344
const complexity = getComplexity({
4445
schema,
4546
operationName: request.operationName,
@@ -50,9 +51,9 @@ export class ComplexityPlugin implements ApolloServerPlugin {
5051
simpleEstimator({ defaultComplexity: 1 }),
5152
],
5253
});
53-
if (complexity >= 20) {
54+
if (complexity > maxComplexity) {
5455
throw new GraphQLError(
55-
`Query is too complex: ${complexity}. Maximum allowed complexity: 20`,
56+
`Query is too complex: ${complexity}. Maximum allowed complexity: ${maxComplexity}`,
5657
);
5758
}
5859
console.log('Query Complexity:', complexity);

content/graphql/directives.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ A directive is an identifier preceded by a `@` character, optionally followed by
1010

1111
#### Custom directives
1212

13-
To create a custom schema directive, declare a class which extends the `SchemaDirectiveVisitor` class exported from the `apollo-server` package.
13+
To create a custom schema directive, declare a class which extends the `SchemaDirectiveVisitor` class exported from the `@graphql-tools/utils` package.
1414

1515
```typescript
16-
import { SchemaDirectiveVisitor } from 'apollo-server';
16+
import { SchemaDirectiveVisitor } from '@graphql-tools/utils';
1717
import { defaultFieldResolver, GraphQLField } from 'graphql';
1818

1919
export class UpperCaseDirective extends SchemaDirectiveVisitor {
@@ -32,6 +32,8 @@ export class UpperCaseDirective extends SchemaDirectiveVisitor {
3232

3333
> info **Hint** Note that directives cannot be decorated with the `@Injectable()` decorator. Thus, they are not able to inject dependencies.
3434
35+
> warning **Warning** `SchemaDirectiveVisitor` is exported from the `@graphql-tools/utils` package. Note that the 8.x release of `graphql-tools` removes this export and provides a different and incompatible approach to directives, so make sure to install `@graphql-tools/utils@^7` in your project.
36+
3537
Now, register the `UpperCaseDirective` in the `GraphQLModule.forRoot()` method:
3638

3739
```typescript

content/graphql/plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import {
1515

1616
@Plugin()
1717
export class LoggingPlugin implements ApolloServerPlugin {
18-
requestDidStart(): GraphQLRequestListener {
18+
async requestDidStart(): Promise<GraphQLRequestListener> {
1919
console.log('Request started');
2020
return {
21-
willSendResponse() {
21+
async willSendResponse() {
2222
console.log('Will send response');
2323
},
2424
};

content/graphql/quick-start.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,26 @@ definitionsFactory.generate({
202202
});
203203
```
204204

205+
#### Apollo Sandbox
206+
207+
To use [Apollo Sandbox](https://www.apollographql.com/blog/announcement/platform/apollo-sandbox-an-open-graphql-ide-for-local-development/) instead of the `graphql-playground` as a GraphQL IDE for local development, use the following configuration:
208+
209+
```typescript
210+
import { Module } from '@nestjs/common';
211+
import { GraphQLModule } from '@nestjs/graphql';
212+
import { ApolloServerPluginLandingPageLocalDefault } from 'apollo-server-core';
213+
214+
@Module({
215+
imports: [
216+
GraphQLModule.forRoot({
217+
playground: false,
218+
plugins: [ApolloServerPluginLandingPageLocalDefault()],
219+
}),
220+
],
221+
})
222+
export class AppModule {}
223+
```
224+
205225
#### Example
206226

207227
A fully working schema first sample is available [here](https://github.com/nestjs/nest/tree/master/sample/12-graphql-schema-first).

content/graphql/scalars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The code-first approach ships with five scalars in which three of them are simpl
1010
- `Int` (alias for `GraphQLInt`) - a signed 32‐bit integer
1111
- `Float` (alias for `GraphQLFloat`) - a signed double-precision floating-point value
1212
- `GraphQLISODateTime` - a date-time string at UTC (used by default to represent `Date` type)
13-
- `GraphQLTimestamp` - a numeric string which represents time and date as number of milliseconds from start of UNIX epoch
13+
- `GraphQLTimestamp` - a signed integer which represents date and time as number of milliseconds from start of UNIX epoch
1414

1515
The `GraphQLISODateTime` (e.g. `2019-12-03T09:54:33Z`) is used by default to represent the `Date` type. To use the `GraphQLTimestamp` instead, set the `dateScalarMode` of the `buildSchemaOptions` object to `'timestamp'` as follows:
1616

content/microservices/mqtt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### MQTT
22

3-
[MQTT](https://mqtt.org/) (Message Queuing Telemetry Transport) is an open source, lightweight messaging protocol, optimized for high-latency. This protocol provides a scalable and cost-efficient way to connect devices using a **publish/subscribe** model. A communication system built on MQTT consists of the publishing server, a broker and one or more clients. It is designed for constrained devices and low-bandwidth, high-latency or unreliable networks.
3+
[MQTT](https://mqtt.org/) (Message Queuing Telemetry Transport) is an open source, lightweight messaging protocol, optimized for low latency. This protocol provides a scalable and cost-efficient way to connect devices using a **publish/subscribe** model. A communication system built on MQTT consists of the publishing server, a broker and one or more clients. It is designed for constrained devices and low-bandwidth, high-latency or unreliable networks.
44

55
#### Installation
66

0 commit comments

Comments
 (0)