Skip to content

Commit

Permalink
Add example mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianfreeman committed Nov 4, 2024
1 parent ffff5e9 commit 583ebb7
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
65 changes: 64 additions & 1 deletion graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"queryType": {
"name": "Query"
},
"mutationType": null,
"mutationType": {
"name": "Mutation"
},
"subscriptionType": null,
"types": [
{
Expand Down Expand Up @@ -115,6 +117,67 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Mutation",
"description": null,
"isOneOf": null,
"fields": [
{
"name": "add",
"description": null,
"args": [
{
"name": "numberOne",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "numberTwo",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "Pokemon",
Expand Down
6 changes: 6 additions & 0 deletions src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import PokemonAPI from './utils/pokeapi'

const createResolvers = (context: Context): Resolvers<any> => {
return {
Mutation: {
add: async (_parent, { numberOne, numberTwo }, { cache }) => {
return numberOne + numberTwo
},
},

Query: {
movies: async () => {
// You can access the context object to access any
Expand Down
4 changes: 4 additions & 0 deletions src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ type Query {
movies: [Movie!]!
pokemon(id: ID!): Pokemon
}

type Mutation {
add(numberOne: Int!, numberTwo: Int!): Int!
}

0 comments on commit 583ebb7

Please sign in to comment.