First of all, I’m trying to move a fetch from an express api endpoint into a graphql datasource. In playground when I call the query it returns the exact data I’m looking for, but with this same exact query is called on client (react) It repeatedly fails.
My first guess was it is potentially the custom scalar I’m using but I have no idea, this is my second time using datasources.
My client query
// Drops
export const GET_DROPS = gql`
query getDrops {
getDrops
}
`;
const { data, loading, error } = useQuery(queries.GET_DROPS);
data is always undefined.
Resolver on Server
import GraphQLJSON from 'graphql-type-json';
export default {
JSON: GraphQLJSON,
Query: {
getDrops: async (_source, _args, { dataSources }) => {
const data = await dataSources.dropsAPI.fetchDrops();
return data.result.data;
}
}
};
Schema on Server
export default gql`
scalar JSON
extend type Query {
getDrops: JSON
}
`;