howtographql / graphql-js

https://www.howtographql.com/graphql-js/1-getting-started/
363 stars 126 forks source link

Suggestion: Please include all CRUD operations #59

Open ZachCMP opened 5 years ago

ZachCMP commented 5 years ago

First off, great tutorial and very helpful. Somewhere near the end of chapter 3 or 4 you pose a challenge the write the rest of the CRUD operations for the Link type:

 type Query {
  # Fetch a single link by its `id`
  link(id: ID!): Link
}

type Mutation {
  # Update a link
  updateLink(id: ID!, url: String, description: String): Link

  # Delete a link
  deleteLink(id: ID!): Link
}

I thought that was a great challenge, and I went ahead and did it. However, that challenge was given before the Prisma integration, which involved refactoring all of the resolvers. That broke the challenge mutations, and they were never revisited again, even in the GitHub repo for the finished project. I really wish you had revisited those other mutations after the Prisma integration to round out all of the operations.

I went ahead and implemented them myself using the Prisma docs and Google, and there was some great non-trivial stuff to solve in there, especially around deleting and how to handle cascade deletes.

I understand that going into all of that is more relevant to Prisma than GraphQL; But I think that if you're going to bring in Prisma as a core part of the tutorial, you should cover all the operations. It would make the final project feel more complete. Plus, going back to solve an earlier challenge with new tools makes for a more compelling tutorial.

Just my $0.02

DannyBoyNYC commented 4 years ago

If you have a repo which implements the CRUD operations could you share it?