Last active
August 4, 2021 19:13
-
-
Save yusinto/d8506184efb73b7214be9beaa4d150c1 to your computer and use it in GitHub Desktop.
Graphql mutation using graphql-request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const updateCountryGraphqlRequest = async (countryId, happinessFactor, population) => { | |
const query = ` | |
mutation updateCountry ($countryId: ID!, $happinessFactor: Int!, $population: Int!) { | |
updateCountry(id: $countryId, happinessFactor: $happinessFactor, population: $population) { id } | |
} | |
`; | |
const variables = { | |
countryId, | |
happinessFactor, | |
population, | |
}; | |
const data = await graphqlRequest.request(query, variables); | |
return data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment