0
0
GraphQLquery~10 mins

Prisma ORM with GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the resolver code to fetch all users using Prisma.

GraphQL
const resolvers = { Query: { users: async () => await prisma.user.[1]() } };
Drag options to blanks, or click blank then click option'
AgetAll
BfindMany
ClistUsers
DfetchAll
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like getAll or fetchAll which are not Prisma methods.
Trying to use listUsers which is not a Prisma client method.
2fill in blank
medium

Complete the resolver code to fetch all posts using Prisma client.

GraphQL
const resolvers = { Query: { posts: async () => await prisma.post.[1]() } };
Drag options to blanks, or click blank then click option'
AfindMany
Bfetch
Clist
DgetAll
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like getAll or fetch.
Confusing with list which is not a Prisma method.
3fill in blank
hard

Fix the error in the mutation to create a new user with Prisma.

GraphQL
mutation { createUser(data: { name: "Alice", email: "alice@example.com" }) { [1] } }
Drag options to blanks, or click blank then click option'
Aid name email
Bcreate
Cuser
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to put 'create' or 'data' which are not valid field selections.
Using 'user' which is not a field but a type.
4fill in blank
hard

Fill both blanks to write a Prisma query that finds a unique user by email.

GraphQL
const user = await prisma.user.[1]({ where: { email: [2] } });
Drag options to blanks, or click blank then click option'
AfindUnique
B"alice@example.com"
CfindMany
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using findMany which returns multiple records.
Not putting the email value in quotes.
5fill in blank
hard

Fill all three blanks to write a mutation that updates a user's name by id using Prisma.

GraphQL
const updatedUser = await prisma.user.[1]({ where: { id: [2] }, data: { name: [3] } });
Drag options to blanks, or click blank then click option'
Aupdate
B42
C"Bob"
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using create instead of update.
Not quoting the name string.
Putting the id in quotes when it should be a number.