I'm facing an issue with my graphql mutation because of the error below:
"errors": [
{
"message": "Unknown type \"GenderInput\".",
"locations": [
{
"line": 1,
"column": 37
}
],
"extensions": {
"code": "GRAPHQL_VALIDATION_FAILED",
"stacktrace": [
"GraphQLError: Unknown type \"GenderInput\".",`
This problem arose after I created a custom input type called GenderInput
.
Here is the frontend mutation code:
export const CALCULATE_CALORIES = gql`
mutation calculateCalories(
$gender: GenderInput!
$weight: String!
$activityLevel: Float!
$goal: GoalInput!
$user_id: String!
) {
calculateCalories(
gender: $gender
weight: $weight
activityLevel: $activityLevel
goal: $goal
user_id: $user_id
)
}
`;
On the backend, in the TypeDefinitions File, I have defined GenderInput correctly according to the schema provided. However, despite restarting Apollo server, the error persists. Any insight on resolving this would be helpful.
export const typeDefsWorkout = `#graphql
type exercise {
id: ID!
name: String!
muscletrained: String
user_id: String!
}
// Rest of the Type Definitions...
`;
The issue began when I added the custom input type (GenderInput). I'd appreciate any assistance in solving this error.