Skip to content

Commit dce0c48

Browse files
committed
addtional changes
1 parent b7692fe commit dce0c48

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

content/graphql/mapped-types.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
As you build out features like CRUD (Create/Read/Update/Delete) it's often useful to construct variants on a base entity type. Nest provides several utility functions that perform type transformations to make this task more convenient.
66

7-
#### Partial: PartialType() function
7+
#### Partial
88

99
When building input validation types (also called DTOs), it's often useful to build **create** and **update** variations on the same type. For example, the **create** variant may require all fields, while the **update** variant may make all fields optional.
1010

@@ -42,7 +42,7 @@ The `PartialType()` function takes an optional second argument that is a referen
4242
export class UpdateUserInput extends PartialType(User, ObjectType) {}
4343
```
4444

45-
#### Pick: PickType() function
45+
#### Pick
4646

4747
The `PickType()` function constructs a new type (class) by picking a set of properties from an input type. For example, suppose we start with a type like:
4848

@@ -69,7 +69,7 @@ export class UpdateEmailInput extends PickType(CreateUserInput, ['email']) {}
6969

7070
> info **Hint** The `PickType()` function is imported from the `@nestjs/graphql` package.
7171
72-
#### Omit: OmitType() function
72+
#### Omit
7373

7474
The `OmitType()` function constructs a type by picking all properties from an input type and then removing a particular set of keys. For example, suppose we start with a type like:
7575

content/graphql/mutations.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ async upvotePost(
5050
) {}
5151
```
5252

53-
// Should we add note about Inheritance here? (input types inheritance)
54-
5553
#### Schema first
5654

5755
Let's extend our `AuthorResolver` used in the previous section (see [resolvers](/graphql/resolvers)).

content/graphql/quick-start.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ A fully working schema first sample is available [here](https://github.com/nestj
173173

174174
#### Accessing generated schema
175175

176-
To access the generated schema (in either the code first or schema first approach), use the `GraphQLSchemaHost` class:
176+
In some circumstances (for example end-to-end tests), you may want to get a reference to the generated schema object. In end-to-end tests, you can then run queries using the `graphql` object without using any HTTP listeners.
177+
178+
You can access the generated schema (in either the code first or schema first approach), using the `GraphQLSchemaHost` class:
177179

178180
```typescript
179181
const { schema } = app.get(GraphQLSchemaHost);

content/graphql/resolvers-map.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ Base `@ArgsType()` class:
315315
```typescript
316316
@ArgsType()
317317
class PaginationArgs {
318-
@Field((type) => Int)
318+
@Field(type => Int)
319319
offset: number = 0;
320320

321-
@Field((type) => Int)
321+
@Field(type => Int)
322322
limit: number = 10;
323323
}
324324
```
@@ -342,7 +342,7 @@ The same approach can be taken with `@ObjectType()` objects. Define generic prop
342342
```typescript
343343
@ObjectType()
344344
class Character {
345-
@Field((type) => Int)
345+
@Field(type => Int)
346346
id: number;
347347

348348
@Field()
@@ -366,7 +366,7 @@ You can use inheritance with a resolver as well. You can ensure type safety by c
366366
function BaseResolver<T extends Type<unknown>>(classRef: T): any {
367367
@Resolver({ isAbstract: true })
368368
abstract class BaseResolverHost {
369-
@Query((type) => [classRef], { name: `findAll${classRef.name}` })
369+
@Query(type => [classRef], { name: `findAll${classRef.name}` })
370370
async findAll(): Promise<T[]> {
371371
return [];
372372
}
@@ -411,22 +411,22 @@ import { Type } from '@nestjs/common';
411411
export function Paginated<T>(classRef: Type<T>) {
412412
@ObjectType(`${classRef.name}Edge`)
413413
abstract class EdgeType {
414-
@Field((type) => String)
414+
@Field(type => String)
415415
cursor: string;
416416

417-
@Field((type) => classRef)
417+
@Field(type => classRef)
418418
node: T;
419419
}
420420

421421
@ObjectType({ isAbstract: true })
422422
abstract class PaginatedType {
423-
@Field((type) => [EdgeType], { nullable: true })
423+
@Field(type => [EdgeType], { nullable: true })
424424
edges: EdgeType[];
425425

426-
@Field((type) => [classRef], { nullable: true })
426+
@Field(type => [classRef], { nullable: true })
427427
nodes: T[];
428428

429-
@Field((type) => Int)
429+
@Field(type => Int)
430430
totalCount: number;
431431

432432
@Field()

content/graphql/schema-generator.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ const schema = await gqlSchemaFactory.create([
2727
]);
2828
```
2929

30-
It also allows several options:
30+
It also takes a second optional argument with an options object:
3131

3232
```typescript
3333
const schema = await gqlSchemaFactory.create([RecipesResolver], {
3434
skipCheck: true,
3535
orphanedTypes: [],
3636
});
3737
```
38+
39+
- `skipCheck`: ignore schema validation; boolean, defaults to `false`
40+
- `orphanedTypes`: list of classes that are not explicitly referenced (not part of the object graph) to be generated. Normally, if a class is declared but isn't otherwise referenced in the graph, it's omitted. The property value is an array of class references.
41+

0 commit comments

Comments
 (0)