Hi community
I am having an issue where I need to send an enum in a mutation request, but I am not being successful in finding the right way to do so. Can someone help me with it? Thank you!
schema.graphql
enum OnboardingStage {
TRACKING_SETTING
}
mutations.js
import { gql } from "@apollo/client";
export const resolvers = {
OnboardingStage: {
TRACKING_SETTING: "TRACKING_SETTING" },
};
export const SIGNUP_USER_TRACKING = gql`
mutation SignupPatientSubmitAllowedTrackingSetting(
$signupTrackingSetting: PatientSignupTrackingSetting!
) {
signupPatientSubmitAllowedTrackingSetting(
signupTrackingSetting: $signupTrackingSetting
) {
allowTracking
onboardingStage
}
}
`;
App.js
import { useMutation } from "@apollo/client";
const [alert, setAlert] = useState(true);
const [signupPatientSubmitAllowedTrackingSetting, { data, loading, error }] =
useMutation(SIGNUP_USER_TRACKING, {
errorPolicy: "all",
onCompleted(data) {
console.log(data);
},
});
const handleTracking = async (answer) => {
try {
await signupPatientSubmitAllowedTrackingSetting({
variables: {
signupTrackingSetting: {
trackingSetting: {
allowTracking: answer,
},
//here is supposed to be an enum not a string
onboardingStage: "TRACKING_SETTING",
},
},
});
setAlert(false);
} catch (e) {
console.log(e);
}
};```
log:
Submission error! ApolloError: Response not successful: Received status code 400
network response:
{"errors":[{"message":"Unsupported feature (@line:column 3:5):The argument '$signupTrackingSetting' is a variable value. Variables are not currently supported here.\nGraphQL operation that failed: SignupPatientSubmitAllowedTrackingSetting","locations":[{"line":0,"column":0}]}]}