I have an object input and want to pass it to mutation:
export enum RatingType {
GENERAL = 'GENERAL',
ADULT = 'ADULT',
}
const input = {
id: '123456789',
name: 'yourname',
ratingType: RatingType.ADULT
}
How to pass input into mutation like this:
mutation = `mutation updateUser{
user: {
id: "1234567890",
name: "yourname",
ratingType: ADULT,
}
}`
i tried as below
import {request} from 'graphql-request';
const mutation = `mutation updateUser{
user: {
${JSON.stringify(input)}
}
}`
const response = await request('http://localhost:3002/graphql', mutation);
but mutation doesn't recognize:
"id" must be id
"name" must be name
"ratingType" must be ratingType
'123456789' must be "123456789"
'yourname' must be "yourname"
'ADULT' must be ADULT
Please give me advice
Thanks.