GraphQL Schema to handle mixed types

后端 未结 3 1081
遥遥无期
遥遥无期 2021-02-09 20:52

I\'ve recently started to research the possibility of using GraphQL for requesting dynamic data configurations. The very first thing that jumps out at me is the strongly-typed c

3条回答
  •  名媛妹妹
    2021-02-09 21:40

    If data is completely JSON and you would rather preserve them as is, check out JSON scalar type. Basically,

    import { GraphQLObjectType } from 'graphql';
    import GraphQLJSON from 'graphql-type-json';
    
    export default new GraphQLObjectType({
      name: 'MyType',
      fields: {
        myField: { type: GraphQLJSON },
      },
    });
    

提交回复
热议问题