Within the server environment, I have defined the enum and query in the schema:
type Query {
hello: String!
getData(dataType: DataType!): [DataPoint]
}
enum DataType {
ACCOUNT,
USER,
COMPANY
}
...
Now, on the client side of things:
export const GET_DATA = gql`
query($dataType: DataType) {
getData(dataType: $dataType) {
...
}
}
`;
Every attempt to execute the query within the ApolloClient leads to a validation error. This occurs because Apollo does not interpret the value as a string; instead, it expects just the variable name like ACCOUNT or USER. Even providing integer values as input does not resolve this issue.
const dataResponse = useQuery(GET_DATA, {
variables: { dataType: "ACCOUNT" },
});
What modifications do I need to make either in the server-side or client-side implementation so that I can correctly pass the Enum value as a variable? It would be ideal if there was a way to input the string value directly into the useQuery method.