在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):taion/graphql-type-json开源软件地址(OpenSource Url):https://github.com/taion/graphql-type-json开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):graphql-type-jsonJSON scalar types for GraphQL.js. UsageThis package exports a JSON value scalar GraphQL.js type: import GraphQLJSON from 'graphql-type-json'; It also exports a JSON object scalar type: import { GraphQLJSONObject } from 'graphql-type-json'; These types can also be imported as follows using CommonJS: const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json');
Programmatically-constructed schemasYou can use this in a programmatically-constructed schema as with any other scalar type: import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';
export default new GraphQLObjectType({
name: 'MyType',
fields: {
myValue: { type: GraphQLJSON },
myObject: { type: GraphQLJSONObject },
},
}); GraphQL-toolsSDL withWhen using the SDL with GraphQL-tools, define import { makeExecutableSchema } from 'graphql-tools';
import GraphQLJSON, { GraphQLJSONObject } from 'graphql-type-json';
const typeDefs = `
scalar JSON
scalar JSONObject
type MyType {
myValue: JSON
myObject: JSONObject
}
# ...
`;
const resolvers = {
JSON: GraphQLJSON,
JSONObject: GraphQLJSONObject,
};
export default makeExecutableSchema({ typeDefs, resolvers }); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论