Apollo Client not querying custom scalar types

Viewed 97

I've made a datasource API to fetch an external API and retrieve it in JSON format. Everything works perfectly, I can call the query in playground and get all the data.

But when I call that query from the react / apollo client side, the data from the query is always returning null. I'm guessing it has something to do with the scalar type.

Apollo Client Query

// Drops
export const GET_DROPS = gql`
    query getDrops {
        getDrops
    }
`;

Drop Resolver (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;
        }
    }
};

Drop Schema

export default gql`
    scalar JSON

    extend type Query {
        getDrops: JSON
    }
`;
0 Answers
Related