I guess I’m trying to figure out if mutations are only used on the front-end
Yes, sort of!
The flow would be
Mutation getSomeData {}
. Make sure the mutation is defined in the relevant sdl file, so your API side knows how to handle it.- This would invoke your resolver for your mutation in your service
export const getSomeData = () => {
const exeternalData = await fetch('https://api.bazinga.kittens')
return db.table.update({
// .... use your exeternal data here
})
}
Bonus:
If you want to be fancy, you can also make use of caching using Service Caching or GraphQL caching