@graphql-mesh/transport-protobuf 0.0.0-stage → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1225 -0
- package/dist/cjs/index.js +394 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/patchLongJs.js +14 -0
- package/dist/cjs/protobuf/codec.js +393 -0
- package/dist/cjs/protobuf/dial.js +40 -0
- package/dist/cjs/protobuf/mapping.js +226 -0
- package/dist/cjs/utils.js +129 -0
- package/dist/esm/index.js +390 -0
- package/dist/esm/patchLongJs.js +11 -0
- package/dist/esm/protobuf/codec.js +389 -0
- package/dist/esm/protobuf/dial.js +33 -0
- package/dist/esm/protobuf/mapping.js +222 -0
- package/dist/esm/utils.js +122 -0
- package/dist/package.json +61 -0
- package/dist/typings/index.d.cts +41 -0
- package/dist/typings/index.d.ts +41 -0
- package/dist/typings/patchLongJs.d.cts +1 -0
- package/dist/typings/patchLongJs.d.ts +1 -0
- package/dist/typings/protobuf/codec.d.cts +3 -0
- package/dist/typings/protobuf/codec.d.ts +3 -0
- package/dist/typings/protobuf/dial.d.cts +16 -0
- package/dist/typings/protobuf/dial.d.ts +16 -0
- package/dist/typings/protobuf/mapping.d.cts +31 -0
- package/dist/typings/protobuf/mapping.d.ts +31 -0
- package/dist/typings/utils.d.cts +12 -0
- package/dist/typings/utils.d.ts +12 -0
- package/package.json +66 -4
- package/src/index.ts +562 -0
- package/src/patchLongJs.ts +12 -0
- package/src/protobuf/codec.ts +429 -0
- package/src/protobuf/dial.ts +56 -0
- package/src/protobuf/mapping.ts +259 -0
- package/src/utils.ts +158 -0
- package/test/mapping-codec.spec.ts +52 -0
- package/test/utils.spec.ts +182 -0
- package/README.md +0 -3
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
import lodashGet from 'lodash.get';
|
|
3
|
+
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
4
|
+
import { withCancel } from '@graphql-mesh/utils';
|
|
5
|
+
import { status as GrpcStatus, Metadata } from '@grpc/grpc-js';
|
|
6
|
+
function isBlob(input) {
|
|
7
|
+
return input != null && input.stream instanceof Function;
|
|
8
|
+
}
|
|
9
|
+
function isGrpcServiceError(error) {
|
|
10
|
+
return (typeof error === 'object' &&
|
|
11
|
+
error != null &&
|
|
12
|
+
typeof error.code === 'number' &&
|
|
13
|
+
typeof error.details === 'string');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convert a gRPC `ServiceError` into a GraphQLError so gateways do not mask it.
|
|
17
|
+
* Upstream details live under `extensions.grpc` (code, status, details, metadata).
|
|
18
|
+
* Non-ServiceError values are returned unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export function toGrpcGraphQLError(error) {
|
|
21
|
+
if (!isGrpcServiceError(error)) {
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
const status = GrpcStatus[error.code] != null ? String(GrpcStatus[error.code]) : 'UNKNOWN';
|
|
25
|
+
// Do not set `originalError` to the raw ServiceError — Envelop's maskedErrors
|
|
26
|
+
// walks originalError and would treat a non-GraphQLError root as unexpected.
|
|
27
|
+
return new GraphQLError(error.message || status, {
|
|
28
|
+
extensions: {
|
|
29
|
+
code: 'DOWNSTREAM_SERVICE_ERROR',
|
|
30
|
+
grpc: {
|
|
31
|
+
code: error.code,
|
|
32
|
+
status,
|
|
33
|
+
details: error.details,
|
|
34
|
+
metadata: error.metadata?.getMap?.(),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function buildGrpcMetadata(metaData, resolverData) {
|
|
40
|
+
if (!metaData) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const meta = new Metadata();
|
|
44
|
+
const entries = Array.isArray(metaData) ? Object.fromEntries(metaData) : metaData;
|
|
45
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
46
|
+
let metaValue = value;
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
// Extract data from context
|
|
49
|
+
metaValue = lodashGet(resolverData.context, value);
|
|
50
|
+
}
|
|
51
|
+
// Ensure that the metadata is compatible with what node-grpc expects
|
|
52
|
+
if (typeof metaValue !== 'string' && !(metaValue instanceof Buffer)) {
|
|
53
|
+
metaValue = JSON.stringify(metaValue);
|
|
54
|
+
}
|
|
55
|
+
if (typeof metaValue === 'string') {
|
|
56
|
+
metaValue = stringInterpolator.parse(metaValue, resolverData);
|
|
57
|
+
}
|
|
58
|
+
meta.add(key, metaValue);
|
|
59
|
+
}
|
|
60
|
+
return meta;
|
|
61
|
+
}
|
|
62
|
+
export function addMetaDataToCall(callFn, input, resolverData, metaData, isResponseStream = false, requestTimeout) {
|
|
63
|
+
const callFnArguments = [];
|
|
64
|
+
if (!isBlob(input)) {
|
|
65
|
+
callFnArguments.push(input);
|
|
66
|
+
}
|
|
67
|
+
const meta = buildGrpcMetadata(metaData, resolverData);
|
|
68
|
+
const callOptions = {};
|
|
69
|
+
if (requestTimeout != null && requestTimeout > 0) {
|
|
70
|
+
callOptions.deadline = Date.now() + requestTimeout;
|
|
71
|
+
}
|
|
72
|
+
const hasCallOptions = Object.keys(callOptions).length > 0;
|
|
73
|
+
if (meta || hasCallOptions) {
|
|
74
|
+
// grpc-js accepts (argument, metadata, options, callback)
|
|
75
|
+
callFnArguments.push(meta ?? new Metadata());
|
|
76
|
+
if (hasCallOptions) {
|
|
77
|
+
callFnArguments.push(callOptions);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
81
|
+
const call = callFn(...callFnArguments, (error, response) => {
|
|
82
|
+
if (error) {
|
|
83
|
+
reject(toGrpcGraphQLError(error));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
resolve(response);
|
|
87
|
+
});
|
|
88
|
+
if (isResponseStream) {
|
|
89
|
+
let isCancelled = false;
|
|
90
|
+
const responseStreamWithCancel = withCancel(call, reason => {
|
|
91
|
+
if (!isCancelled) {
|
|
92
|
+
call.call?.cancelWithStatus(0, reason?.toString() || 'aborted');
|
|
93
|
+
isCancelled = true;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
resolve(responseStreamWithCancel);
|
|
97
|
+
if (isBlob(input)) {
|
|
98
|
+
const blobStream = input.stream();
|
|
99
|
+
blobStream.pipe(call);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return promise;
|
|
103
|
+
}
|
|
104
|
+
export function addExecutionLogicToScalar(nonExecutableScalar, actualScalar) {
|
|
105
|
+
Object.defineProperties(nonExecutableScalar, {
|
|
106
|
+
serialize: {
|
|
107
|
+
value: actualScalar.serialize,
|
|
108
|
+
},
|
|
109
|
+
parseValue: {
|
|
110
|
+
value: actualScalar.parseValue,
|
|
111
|
+
},
|
|
112
|
+
parseLiteral: {
|
|
113
|
+
value: actualScalar.parseLiteral,
|
|
114
|
+
},
|
|
115
|
+
extensions: {
|
|
116
|
+
value: {
|
|
117
|
+
...actualScalar.extensions,
|
|
118
|
+
...nonExecutableScalar.extensions,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphql-mesh/transport-protobuf",
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"graphql": "^16.0.0 || ^17.0.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@apollo/subgraph": "^2.16.0",
|
|
10
|
+
"@graphql-hive/logger": "^1.1.1",
|
|
11
|
+
"@graphql-mesh/cross-helpers": "^0.4.18",
|
|
12
|
+
"@graphql-mesh/string-interpolation": "^0.5.18",
|
|
13
|
+
"@graphql-mesh/transport-common": "^1.1.2",
|
|
14
|
+
"@graphql-mesh/types": "^0.107.3",
|
|
15
|
+
"@graphql-mesh/utils": "^0.107.3",
|
|
16
|
+
"@graphql-tools/utils": "^13.2.2",
|
|
17
|
+
"@grpc/grpc-js": "^1.14.5",
|
|
18
|
+
"@grpc/proto-loader": "^0.8.1",
|
|
19
|
+
"@whatwg-node/disposablestack": "^0.1.0",
|
|
20
|
+
"@whatwg-node/fetch": "^0.12.1",
|
|
21
|
+
"@whatwg-node/promise-helpers": "^2.0.1",
|
|
22
|
+
"graphql-scalars": "^2.0.1",
|
|
23
|
+
"lodash.get": "^4.4.2",
|
|
24
|
+
"long": "4.0.0",
|
|
25
|
+
"protobufjs": "^8.8.1",
|
|
26
|
+
"tslib": "^2.4.0"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "ardatan/graphql-mesh",
|
|
31
|
+
"directory": "packages/transports/protobuf"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22.18.0"
|
|
36
|
+
},
|
|
37
|
+
"main": "cjs/index.js",
|
|
38
|
+
"module": "esm/index.js",
|
|
39
|
+
"typings": "typings/index.d.ts",
|
|
40
|
+
"typescript": {
|
|
41
|
+
"definition": "typings/index.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"type": "module",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./typings/index.d.cts",
|
|
48
|
+
"default": "./cjs/index.js"
|
|
49
|
+
},
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./typings/index.d.ts",
|
|
52
|
+
"default": "./esm/index.js"
|
|
53
|
+
},
|
|
54
|
+
"default": {
|
|
55
|
+
"types": "./typings/index.d.ts",
|
|
56
|
+
"default": "./esm/index.js"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"./package.json": "./package.json"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type GraphQLSchema } from 'graphql';
|
|
2
|
+
import { type Transport } from '@graphql-mesh/transport-common';
|
|
3
|
+
import { type ChannelCredentials, type ChannelOptions } from '@grpc/grpc-js';
|
|
4
|
+
import { DisposableStack } from '@whatwg-node/disposablestack';
|
|
5
|
+
import type { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
6
|
+
import type { Logger } from '@graphql-hive/logger';
|
|
7
|
+
import type { MeshFetch } from '@graphql-mesh/types';
|
|
8
|
+
export interface ProtobufTransportOptions {
|
|
9
|
+
requestTimeout?: number;
|
|
10
|
+
credentialsSsl?: {
|
|
11
|
+
rootCA?: string;
|
|
12
|
+
certChain?: string;
|
|
13
|
+
privateKey?: string;
|
|
14
|
+
};
|
|
15
|
+
useHTTPS?: boolean;
|
|
16
|
+
metaData?: {
|
|
17
|
+
[k: string]: any;
|
|
18
|
+
} | [string, string][];
|
|
19
|
+
channelOptions?: ChannelOptions | [string, string | number][];
|
|
20
|
+
headers?: Record<string, string> | [string, string][];
|
|
21
|
+
}
|
|
22
|
+
export declare class ProtobufTransportHelper extends DisposableStack {
|
|
23
|
+
private subgraphName;
|
|
24
|
+
private baseDir;
|
|
25
|
+
private log;
|
|
26
|
+
private endpoint;
|
|
27
|
+
private config;
|
|
28
|
+
private channelCreds;
|
|
29
|
+
private fetchFn;
|
|
30
|
+
constructor(subgraphName: string, baseDir: string, log: Logger, endpoint: string, config: ProtobufTransportOptions);
|
|
31
|
+
setFetch(fetchFn: MeshFetch | undefined): void;
|
|
32
|
+
getCredentials(): MaybePromise<ChannelCredentials>;
|
|
33
|
+
processDirectives({ schema, creds }: {
|
|
34
|
+
schema: GraphQLSchema;
|
|
35
|
+
creds: ChannelCredentials;
|
|
36
|
+
}): void;
|
|
37
|
+
private createRpcResolverFromDirectiveArgs;
|
|
38
|
+
private createRpcResolver;
|
|
39
|
+
}
|
|
40
|
+
declare const transport: Transport<ProtobufTransportOptions>;
|
|
41
|
+
export default transport;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type GraphQLSchema } from 'graphql';
|
|
2
|
+
import { type Transport } from '@graphql-mesh/transport-common';
|
|
3
|
+
import { type ChannelCredentials, type ChannelOptions } from '@grpc/grpc-js';
|
|
4
|
+
import { DisposableStack } from '@whatwg-node/disposablestack';
|
|
5
|
+
import type { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
6
|
+
import type { Logger } from '@graphql-hive/logger';
|
|
7
|
+
import type { MeshFetch } from '@graphql-mesh/types';
|
|
8
|
+
export interface ProtobufTransportOptions {
|
|
9
|
+
requestTimeout?: number;
|
|
10
|
+
credentialsSsl?: {
|
|
11
|
+
rootCA?: string;
|
|
12
|
+
certChain?: string;
|
|
13
|
+
privateKey?: string;
|
|
14
|
+
};
|
|
15
|
+
useHTTPS?: boolean;
|
|
16
|
+
metaData?: {
|
|
17
|
+
[k: string]: any;
|
|
18
|
+
} | [string, string][];
|
|
19
|
+
channelOptions?: ChannelOptions | [string, string | number][];
|
|
20
|
+
headers?: Record<string, string> | [string, string][];
|
|
21
|
+
}
|
|
22
|
+
export declare class ProtobufTransportHelper extends DisposableStack {
|
|
23
|
+
private subgraphName;
|
|
24
|
+
private baseDir;
|
|
25
|
+
private log;
|
|
26
|
+
private endpoint;
|
|
27
|
+
private config;
|
|
28
|
+
private channelCreds;
|
|
29
|
+
private fetchFn;
|
|
30
|
+
constructor(subgraphName: string, baseDir: string, log: Logger, endpoint: string, config: ProtobufTransportOptions);
|
|
31
|
+
setFetch(fetchFn: MeshFetch | undefined): void;
|
|
32
|
+
getCredentials(): MaybePromise<ChannelCredentials>;
|
|
33
|
+
processDirectives({ schema, creds }: {
|
|
34
|
+
schema: GraphQLSchema;
|
|
35
|
+
creds: ChannelCredentials;
|
|
36
|
+
}): void;
|
|
37
|
+
private createRpcResolverFromDirectiveArgs;
|
|
38
|
+
private createRpcResolver;
|
|
39
|
+
}
|
|
40
|
+
declare const transport: Transport<ProtobufTransportOptions>;
|
|
41
|
+
export default transport;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MappingField } from './mapping.cjs';
|
|
2
|
+
export declare function encodeMessage(fields: MappingField[], args: Record<string, any>, localRoot?: Record<string, any>, thisRoot?: Record<string, any>): Uint8Array;
|
|
3
|
+
export declare function decodeMessage(fields: MappingField[], data: Uint8Array): Record<string, any>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MappingField } from './mapping.js';
|
|
2
|
+
export declare function encodeMessage(fields: MappingField[], args: Record<string, any>, localRoot?: Record<string, any>, thisRoot?: Record<string, any>): Uint8Array;
|
|
3
|
+
export declare function decodeMessage(fields: MappingField[], data: Uint8Array): Record<string, any>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import type { MeshFetch } from '@graphql-mesh/types';
|
|
3
|
+
export declare function isHttpLocation(location: string): boolean;
|
|
4
|
+
export declare function buildRpcPath(service: string | undefined, method: string): string;
|
|
5
|
+
export declare function resolveHttpUrl(location: string, service: string | undefined, method: string): string;
|
|
6
|
+
/** Default Connect unary binary content type; override via `@transport(headers:)` (e.g. Twirp `application/protobuf`). */
|
|
7
|
+
export declare const DEFAULT_PROTOBUF_HTTP_CONTENT_TYPE = "application/proto";
|
|
8
|
+
export declare function httpProtobufUnary(opts: {
|
|
9
|
+
url: string;
|
|
10
|
+
body: Uint8Array;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
fetchFn?: MeshFetch;
|
|
14
|
+
context?: any;
|
|
15
|
+
info?: GraphQLResolveInfo;
|
|
16
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import type { MeshFetch } from '@graphql-mesh/types';
|
|
3
|
+
export declare function isHttpLocation(location: string): boolean;
|
|
4
|
+
export declare function buildRpcPath(service: string | undefined, method: string): string;
|
|
5
|
+
export declare function resolveHttpUrl(location: string, service: string | undefined, method: string): string;
|
|
6
|
+
/** Default Connect unary binary content type; override via `@transport(headers:)` (e.g. Twirp `application/protobuf`). */
|
|
7
|
+
export declare const DEFAULT_PROTOBUF_HTTP_CONTENT_TYPE = "application/proto";
|
|
8
|
+
export declare function httpProtobufUnary(opts: {
|
|
9
|
+
url: string;
|
|
10
|
+
body: Uint8Array;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
fetchFn?: MeshFetch;
|
|
14
|
+
context?: any;
|
|
15
|
+
info?: GraphQLResolveInfo;
|
|
16
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact protobuf mapping dialect (see Mesh protobuf RPC spec).
|
|
3
|
+
* body/selection: fieldId(type): bind with nested { }
|
|
4
|
+
*/
|
|
5
|
+
export type ProtoScalar = 'bool' | 'int32' | 'sint32' | 'uint32' | 'int64' | 'sint64' | 'uint64' | 'fixed32' | 'fixed64' | 'sfixed32' | 'sfixed64' | 'float' | 'double' | 'string' | 'bytes';
|
|
6
|
+
export type ProtoType = {
|
|
7
|
+
kind: 'scalar';
|
|
8
|
+
name: ProtoScalar;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'enum';
|
|
11
|
+
values: Record<string, number>;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'message';
|
|
14
|
+
fields: MappingField[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'repeated';
|
|
17
|
+
element: ProtoType;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'map';
|
|
20
|
+
key: ProtoType;
|
|
21
|
+
value: ProtoType;
|
|
22
|
+
};
|
|
23
|
+
export interface MappingField {
|
|
24
|
+
id: number;
|
|
25
|
+
type: ProtoType;
|
|
26
|
+
/** GraphQL bind path (e.g. year, $args.year, input.movie) or nested omit when type is message with fields */
|
|
27
|
+
bind?: string;
|
|
28
|
+
fields?: MappingField[];
|
|
29
|
+
}
|
|
30
|
+
export declare function parseMapping(source: string): MappingField[];
|
|
31
|
+
export declare function resolveBind(bind: string | undefined, args: Record<string, any>, thisRoot?: Record<string, any>): any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact protobuf mapping dialect (see Mesh protobuf RPC spec).
|
|
3
|
+
* body/selection: fieldId(type): bind with nested { }
|
|
4
|
+
*/
|
|
5
|
+
export type ProtoScalar = 'bool' | 'int32' | 'sint32' | 'uint32' | 'int64' | 'sint64' | 'uint64' | 'fixed32' | 'fixed64' | 'sfixed32' | 'sfixed64' | 'float' | 'double' | 'string' | 'bytes';
|
|
6
|
+
export type ProtoType = {
|
|
7
|
+
kind: 'scalar';
|
|
8
|
+
name: ProtoScalar;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'enum';
|
|
11
|
+
values: Record<string, number>;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'message';
|
|
14
|
+
fields: MappingField[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'repeated';
|
|
17
|
+
element: ProtoType;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'map';
|
|
20
|
+
key: ProtoType;
|
|
21
|
+
value: ProtoType;
|
|
22
|
+
};
|
|
23
|
+
export interface MappingField {
|
|
24
|
+
id: number;
|
|
25
|
+
type: ProtoType;
|
|
26
|
+
/** GraphQL bind path (e.g. year, $args.year, input.movie) or nested omit when type is message with fields */
|
|
27
|
+
bind?: string;
|
|
28
|
+
fields?: MappingField[];
|
|
29
|
+
}
|
|
30
|
+
export declare function parseMapping(source: string): MappingField[];
|
|
31
|
+
export declare function resolveBind(bind: string | undefined, args: Record<string, any>, thisRoot?: Record<string, any>): any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GraphQLScalarType } from 'graphql';
|
|
2
|
+
import type { ResolverData } from '@graphql-mesh/string-interpolation';
|
|
3
|
+
import { Metadata } from '@grpc/grpc-js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert a gRPC `ServiceError` into a GraphQLError so gateways do not mask it.
|
|
6
|
+
* Upstream details live under `extensions.grpc` (code, status, details, metadata).
|
|
7
|
+
* Non-ServiceError values are returned unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toGrpcGraphQLError(error: unknown): unknown;
|
|
10
|
+
export declare function buildGrpcMetadata(metaData: Record<string, string | string[] | Buffer> | [string, string][] | undefined, resolverData: ResolverData): Metadata | undefined;
|
|
11
|
+
export declare function addMetaDataToCall(callFn: any, input: any, resolverData: ResolverData, metaData?: Record<string, string | string[] | Buffer> | [string, string][], isResponseStream?: boolean, requestTimeout?: number): Promise<any>;
|
|
12
|
+
export declare function addExecutionLogicToScalar(nonExecutableScalar: GraphQLScalarType, actualScalar: GraphQLScalarType): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type GraphQLScalarType } from 'graphql';
|
|
2
|
+
import type { ResolverData } from '@graphql-mesh/string-interpolation';
|
|
3
|
+
import { Metadata } from '@grpc/grpc-js';
|
|
4
|
+
/**
|
|
5
|
+
* Convert a gRPC `ServiceError` into a GraphQLError so gateways do not mask it.
|
|
6
|
+
* Upstream details live under `extensions.grpc` (code, status, details, metadata).
|
|
7
|
+
* Non-ServiceError values are returned unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toGrpcGraphQLError(error: unknown): unknown;
|
|
10
|
+
export declare function buildGrpcMetadata(metaData: Record<string, string | string[] | Buffer> | [string, string][] | undefined, resolverData: ResolverData): Metadata | undefined;
|
|
11
|
+
export declare function addMetaDataToCall(callFn: any, input: any, resolverData: ResolverData, metaData?: Record<string, string | string[] | Buffer> | [string, string][], isResponseStream?: boolean, requestTimeout?: number): Promise<any>;
|
|
12
|
+
export declare function addExecutionLogicToScalar(nonExecutableScalar: GraphQLScalarType, actualScalar: GraphQLScalarType): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/transport-protobuf",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "ardatan/graphql-mesh",
|
|
8
|
+
"directory": "packages/transports/protobuf"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.18.0"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/cjs/index.js",
|
|
15
|
+
"module": "dist/esm/index.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/typings/index.d.cts",
|
|
20
|
+
"default": "./dist/cjs/index.js"
|
|
21
|
+
},
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/typings/index.d.ts",
|
|
24
|
+
"default": "./dist/esm/index.js"
|
|
25
|
+
},
|
|
26
|
+
"default": {
|
|
27
|
+
"types": "./dist/typings/index.d.ts",
|
|
28
|
+
"default": "./dist/esm/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"typings": "dist/typings/index.d.ts",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"graphql": "^16.0.0 || ^17.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@apollo/subgraph": "^2.16.0",
|
|
39
|
+
"@graphql-hive/logger": "^1.1.1",
|
|
40
|
+
"@graphql-mesh/cross-helpers": "^0.4.18",
|
|
41
|
+
"@graphql-mesh/string-interpolation": "^0.5.18",
|
|
42
|
+
"@graphql-mesh/transport-common": "^1.1.2",
|
|
43
|
+
"@graphql-mesh/types": "^0.107.3",
|
|
44
|
+
"@graphql-mesh/utils": "^0.107.3",
|
|
45
|
+
"@graphql-tools/utils": "^13.2.2",
|
|
46
|
+
"@grpc/grpc-js": "^1.14.5",
|
|
47
|
+
"@grpc/proto-loader": "^0.8.1",
|
|
48
|
+
"@whatwg-node/disposablestack": "^0.1.0",
|
|
49
|
+
"@whatwg-node/fetch": "^0.12.1",
|
|
50
|
+
"@whatwg-node/promise-helpers": "^2.0.1",
|
|
51
|
+
"graphql-scalars": "^2.0.1",
|
|
52
|
+
"lodash.get": "^4.4.2",
|
|
53
|
+
"long": "4.0.0",
|
|
54
|
+
"protobufjs": "^8.8.1",
|
|
55
|
+
"tslib": "^2.4.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"graphql": "16.14.0"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public",
|
|
62
|
+
"directory": "dist"
|
|
63
|
+
},
|
|
64
|
+
"sideEffects": false,
|
|
65
|
+
"typescript": {
|
|
66
|
+
"definition": "dist/typings/index.d.ts"
|
|
67
|
+
}
|
|
68
|
+
}
|