@graphql-mesh/grpc
Version:
62 lines (61 loc) • 1.81 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.grpcRootJsonDirective = exports.ObjMapScalar = 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.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,
});