I have a Graphql schema that looks like this:
type Mutation {
createUploadUrl(
input: CreateUploadUrl!
): MyResponse!
}
input CreateUploadUrl {
deploymentId: ID!
}
I'm new to Graphql and am getting lost when trying to work out what my query should look like when I submit it via fetch:
fetch('https://example.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation($input: ) {
createUploadUrl($input) {
__typename,
// my values I want to retrieve
// ...
}
}`,
variables: {
input: {deploymentId: "XXX"}
}
}),
})
.then((res) => res.json())
.then((result) => console.log(result));
The above gives me an error: `message: "Syntax Error: Expected Name, found "$"."
How am I supposed to specify a query or mutation that requires an object as a variable? `