diff --git a/website/src/pages/tutorial/basic/08-graph-relations.mdx b/website/src/pages/tutorial/basic/08-graph-relations.mdx index 92806799e5..ca7136b534 100644 --- a/website/src/pages/tutorial/basic/08-graph-relations.mdx +++ b/website/src/pages/tutorial/basic/08-graph-relations.mdx @@ -38,8 +38,8 @@ model Link { model Comment { id Int @id @default(autoincrement()) body String - link Link? @relation(fields: [linkId], references: [id]) - linkId Int? + link Link @relation(fields: [linkId], references: [id]) + linkId Int } ``` @@ -460,7 +460,7 @@ type Comment { } type Query { - link(id: ID): Link + link(id: ID!): Link } ``` diff --git a/website/src/pages/tutorial/basic/09-error-handling.mdx b/website/src/pages/tutorial/basic/09-error-handling.mdx index 7c13806be4..918a9c49d4 100644 --- a/website/src/pages/tutorial/basic/09-error-handling.mdx +++ b/website/src/pages/tutorial/basic/09-error-handling.mdx @@ -327,7 +327,7 @@ string contents using a regex. Add the following code to the `src/schema.ts` file. -```ts filename="src/schema.ts" +```ts filename="src/schema.ts" {5-10,21-26} // ... other code ... import { GraphQLError } from 'graphql' import { Prisma } from '@prisma/client' @@ -355,11 +355,11 @@ const resolvers = { ) } - const comment = await context.prisma.comment + const newComment = await context.prisma.comment .create({ data: { - body: args.body, - linkId + linkId, + body: args.body } }) .catch((err: unknown) => { @@ -374,7 +374,7 @@ const resolvers = { } return Promise.reject(err) }) - return comment + return newComment } } } diff --git a/website/src/pages/tutorial/basic/10-filtering-and-pagination.mdx b/website/src/pages/tutorial/basic/10-filtering-and-pagination.mdx index bc27851c02..ba129d7dba 100644 --- a/website/src/pages/tutorial/basic/10-filtering-and-pagination.mdx +++ b/website/src/pages/tutorial/basic/10-filtering-and-pagination.mdx @@ -77,15 +77,11 @@ query { id description url - postedBy { - id - name - } } } ``` -![sample query](https://i.imgur.com/tICYe2e.png) +![sample query](https://i.imgur.com/qODhFPW.png) ## Pagination @@ -131,7 +127,7 @@ Now, adjust the field resolver function implementation: And now adjust the implementation of the `Query.feed` resolver function: -```ts filename="src/schema.ts" +```ts filename="src/schema.ts" {7,20-21} const resolvers = { // ... other resolvers maps ... Query: { @@ -177,7 +173,7 @@ query { } ``` -![test the pagination API ](https://i.imgur.com/XeZgSJo.png) +![test the pagination API ](https://i.imgur.com/VZzIeyJ.png) ## Pagination Field Argument Sanitization @@ -200,7 +196,7 @@ Fetching 0 records does not make sense. Adjust the current schema resolver implementation according to the following. -```ts filename="src/schema.ts" +```ts filename="src/schema.ts" {4-11,31-35,40} // ... other code ... import { GraphQLError } from 'graphql' diff --git a/website/src/pages/tutorial/basic/11-setting-up-graphql-code-generator.mdx b/website/src/pages/tutorial/basic/11-setting-up-graphql-code-generator.mdx index 73c206cf10..08931b5fc1 100644 --- a/website/src/pages/tutorial/basic/11-setting-up-graphql-code-generator.mdx +++ b/website/src/pages/tutorial/basic/11-setting-up-graphql-code-generator.mdx @@ -70,10 +70,10 @@ const config: CodegenConfig = { generates: { 'src/schema': defineConfig({ // (3) - resolverGeneration: 'minimal' // (4) + resolverGeneration: 'minimal', // (4) typesPluginsConfig: { - contextType: "../context#GraphQLContext", // (5) - }, + contextType: '../context#GraphQLContext' // (5) + } }) } } @@ -156,7 +156,7 @@ export const feed: NonNullable = async (_parent, _arg, _ It should be trivial to bring the existing logic over: ```ts filename="src/schema/base/resolvers/Query/feed.ts" -export const feed: NonNullable = async (_parent, _arg, context) => { +export const feed: NonNullable = async (_parent, args, context) => { const where = args.filterNeedle ? { OR: [