I have a mutation like this -
import gql from "graphql-tag";
const completedAt = new Date().toISOString();
export const CREATE_TODO = gql`
mutation($body: String!, $completedAt: DateTime = completedAt) {
createTodo(input: { body: $body, completed_at: $completedAt }) {
id
body
}
}
`;
When I call this mutation I get the error
GraphQL error: Default value for $completedAt doesn't match type DateTime in React Apollo
How do I solve this? I have tried JSON.stringify(new Date().toISOString()) too but no luck :(
Also, note that this works -
import gql from "graphql-tag";
const completedAt = JSON.stringify(new Date().toISOString());
export const CREATE_TODO = gql`
mutation($body: String!) {
createTodo(input: { body: $body, completed_at: ${completedAt} }) {
id
body
}
}
`;