How to use graphql-type-json package with GraphQl

前端 未结 2 897
长情又很酷
长情又很酷 2021-01-18 12:39

I can\'t get GraphQL to recognize the JSON scalar type.

I followed the [apollo docs] (http://dev.apollodata.com/tools/graphql-tools/scalars.html#Using-a-package) to

相关标签:
2条回答
  • 2021-01-18 13:08

    I resolved custom scalar JSON like this in resolvers

     JSON: {
    
    __serialize(value) {
        return GraphQLJSON.parseValue(value);
    } }
    

    And It worked fine for me. I think it will help you

    0 讨论(0)
  • 2021-01-18 13:10

    I couldn't get a custom scalar working with a text-based schema (using buildSchema('...') from the core "graphql" library), but it worked when I built the schema programmatically from scratch (using new GraphQLSchema(...)).

    0 讨论(0)
提交回复
热议问题