-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection of common scenarios #35
Comments
This was referenced Dec 31, 2017
ricksre8
added a commit
to ricksre8/graphql-boilerplates
that referenced
this issue
Nov 28, 2021
collecting them in graphql-boilerplates/node-graphql-server#35 instead
benjaminlee1128
pushed a commit
to benjaminlee1128/node-graphql
that referenced
this issue
Aug 5, 2024
collecting them in graphql-boilerplates/node-graphql-server#35 instead
liubomyr191
pushed a commit
to liubomyr191/GraphQL-node
that referenced
this issue
Nov 9, 2024
collecting them in graphql-boilerplates/node-graphql-server#35 instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scenarios
The following is a collection of commons scenarios, with the goal of providing step-by-step explanations of how to go about them.
All scenarios are based on
typescript-basic
.Adding fields to an existing type
Example & Instructions
Example
Adding a new address field to the user type in the database, with the purpose of exposing it in the application API as well.
Instructions
1. Adding the field to the data model
in
database/datamodel.graphql
:type User { id: ID! @unique email: String! @unique password: String! name: String! posts: [Post!]! @relation(name: "UserPosts") + address: String }
2. Deploying the updated data model
This will
database/schema.graphql
3. Adding the field to the application schema
in
src/schema.graphql
:type User { id: ID! email: String! name: String! posts: [Post!]! + address: String }
Adding a new resolver to the GraphQL server
Example & Instructions
Example
Suppose we want to add a custom resolver to delete a post.
Instructions
Add a new
delete
field to the Mutation type insrc/schema.graphql
type Mutation { createDraft(title: String!, text: String): Post publish(id: ID!): Post + delete(id: ID!): Post }
Add a
delete
resolver to Mutation part ofsrc/index.js
Run
yarn start
.Then we can run the following mutation to delete a post:
Further resolver-centric scenarios
Other scenarios
The text was updated successfully, but these errors were encountered: