UNPKG

@graphql-mesh/grpc

Version:
71 lines (70 loc) 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.grpcRootJsonDirective = exports.ObjMapScalar = exports.EnumDirective = exports.grpcConnectivityStateDirective = exports.grpcMethodDirective = void 0; const graphql_1 = require("graphql"); exports.grpcMethodDirective = new graphql_1.GraphQLDirective({ name: 'grpcMethod', locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION], args: { rootJsonName: { type: graphql_1.GraphQLString, }, objPath: { type: graphql_1.GraphQLString, }, methodName: { type: graphql_1.GraphQLString, }, responseStream: { type: graphql_1.GraphQLBoolean, }, }, }); exports.grpcConnectivityStateDirective = new graphql_1.GraphQLDirective({ name: 'grpcConnectivityState', locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION], args: { rootJsonName: { type: graphql_1.GraphQLString, }, objPath: { type: graphql_1.GraphQLString, }, }, }); exports.EnumDirective = new graphql_1.GraphQLDirective({ name: 'enum', locations: [graphql_1.DirectiveLocation.ENUM_VALUE], args: { value: { type: graphql_1.GraphQLString, }, }, }); exports.ObjMapScalar = new graphql_1.GraphQLScalarType({ name: 'ObjMap', serialize: value => JSON.stringify(value), parseValue: value => JSON.parse(value.toString()), parseLiteral: ast => { if (ast.kind === 'StringValue') { return JSON.parse(ast.value); } return null; }, }); exports.grpcRootJsonDirective = new graphql_1.GraphQLDirective({ name: 'grpcRootJson', locations: [graphql_1.DirectiveLocation.OBJECT], args: { name: { type: graphql_1.GraphQLString, }, rootJson: { type: exports.ObjMapScalar, }, loadOptions: { type: exports.ObjMapScalar, }, }, isRepeatable: true, });