Skip to content

Commit a557268

Browse files
author
monica.lopez-gris
committed
update docs
1 parent daf0edd commit a557268

2 files changed

Lines changed: 31 additions & 9 deletions

File tree

documentation/guides-grapql.asciidoc

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ import { Document } from 'mongoose';
5454
@Schema()
5555
export class Todo extends Document {
5656
@Prop()
57-
id: number;
57+
id!: number;
5858
5959
@Prop()
60-
task: string;
60+
task: string | undefined;
6161
6262
@Prop()
63-
status: boolean;
63+
status: boolean | undefined;
6464
}
6565
6666
export const TodoSchema = SchemaFactory.createForClass(Todo);
@@ -97,7 +97,7 @@ export class TodosService {
9797
9898
async create(task: string): Promise<Todo> {
9999
const object = {
100-
task: task
100+
task: task,
101101
}
102102
const createdTodo = new this.todoModel(object);
103103
return createdTodo.save();
@@ -140,7 +140,7 @@ To install it:
140140
yarn add @nestjs/graphql graphql-tools graphql apollo-server-express
141141
----
142142

143-
=== Squema first
143+
=== Schema first
144144
This tutorial uses the schema first method.
145145

146146
First we need to import GraphQLModule to our `app.module.ts`.
@@ -222,9 +222,31 @@ type Query {
222222

223223
Here we have also an argument decorator `@Args` which is an object with the arguments passed into the field in the query.
224224

225-
Learn more about resolvers and their argument decorators on the https://docs.nestjs.com/graphql/resolvers#schema-first[NestJS documentation].
225+
Learn more about resolvers, mutations and their argument decorators on the https://docs.nestjs.com/graphql/resolvers#schema-first[NestJS documentation].
226+
226227

228+
Now start the server and go to `http://localhost:3000/graphql` you should see a playground, here you can test your resolvers.
229+
230+
For try querys you only need to write a json with what you need:
231+
232+
[source,typescript]
233+
----
234+
{
235+
findAll{
236+
task
237+
}
238+
}
239+
----
227240

241+
To test the mutation you can:
228242

229-
=== Code first
230-
On this approach we are going to use decorators to generate de schema.
243+
[source,typescript]
244+
----
245+
mutation{
246+
createTodo (
247+
task: "aasas"
248+
){
249+
id, task
250+
}
251+
}
252+
----

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@
9696
"pre-commit": "lerna run lint"
9797
}
9898
}
99-
}
99+
}

0 commit comments

Comments
 (0)