UNPKG

4.2 kBTypeScriptView Raw
1import type { ExecutionArgs } from 'graphql';
2import type { AgentOptions } from './agent';
3import type { SchemaReporter } from './reporting';
4import type { OperationsStore } from './operations-store';
5export interface HiveClient {
6 info(): Promise<void>;
7 reportSchema: SchemaReporter['report'];
8 collectUsage(args: ExecutionArgs): CollectUsageCallback;
9 operationsStore: OperationsStore;
10 dispose(): Promise<void>;
11}
12export declare type AsyncIterableIteratorOrValue<T> = AsyncIterableIterator<T> | T;
13export declare type CollectUsageCallback = (result: AsyncIterableIteratorOrValue<GraphQLErrorsResult>) => void;
14export interface ClientInfo {
15 name: string;
16 version: string;
17}
18export interface Logger {
19 info(msg: string): void;
20 error(error: any, ...data: any[]): void;
21}
22export interface HiveUsagePluginOptions {
23 /**
24 * Custom endpoint to collect schema usage
25 *
26 * Points to Hive by default
27 */
28 endpoint?: string;
29 /**
30 * Extract client info from GraphQL Context
31 */
32 clientInfo?(context: any): null | undefined | ClientInfo;
33 /**
34 * Generate hash of an operation (useful for persisted operations)
35 */
36 operationHash?(args: ExecutionArgs): string | null | undefined;
37 /**
38 * Hive uses LRU cache to store info about operations.
39 * This option represents the maximum size of the cache.
40 *
41 * Default: 1000
42 */
43 max?: number;
44 /**
45 * Hive uses LRU cache to store info about operations.
46 * This option represents the time-to-live of every cached operation.
47 *
48 * Default: no ttl
49 */
50 ttl?: number;
51 /**
52 * A list of operations (by name) to be ignored by Hive.
53 */
54 exclude?: string[];
55 /**
56 * Sample rate to determine sampling.
57 * 0.0 = 0% chance of being sent
58 * 1.0 = 100% chance of being sent.
59 *
60 * Default: 1.0
61 */
62 sampleRate?: number;
63 /**
64 * (Experimental) Enables collecting Input fields usage based on the variables passed to the operation.
65 *
66 * Default: false
67 */
68 processVariables?: boolean;
69}
70export interface HiveReportingPluginOptions {
71 /**
72 * Custom endpoint to collect schema reports
73 *
74 * Points to Hive by default
75 */
76 endpoint?: string;
77 /**
78 * Author of current version of the schema
79 */
80 author: string;
81 /**
82 * Commit SHA hash (or any identifier) related to the schema version
83 */
84 commit: string;
85 /**
86 * URL to the service (use only for distributed schemas)
87 */
88 serviceUrl?: string;
89 /**
90 * Name of the service (use only for distributed schemas)
91 */
92 serviceName?: string;
93}
94export interface HiveOperationsStorePluginOptions {
95 /**
96 * Custom endpoint to fetch stored operations
97 *
98 * Points to Hive by default
99 */
100 endpoint?: string;
101}
102export interface HivePluginOptions {
103 /**
104 * Enable/Disable Hive
105 *
106 * Default: true
107 */
108 enabled?: boolean;
109 /**
110 * Debugging mode
111 *
112 * Default: false
113 */
114 debug?: boolean;
115 /**
116 * Access Token
117 */
118 token: string;
119 agent?: Omit<AgentOptions, 'endpoint' | 'token' | 'enabled' | 'debug'>;
120 /**
121 * Collects schema usage based on operations
122 *
123 * Disabled by default
124 */
125 usage?: HiveUsagePluginOptions | boolean;
126 /**
127 * Schema reporting
128 *
129 * Disabled by default
130 */
131 reporting?: HiveReportingPluginOptions | false;
132 /**
133 * Operations Store
134 */
135 operationsStore?: HiveOperationsStorePluginOptions;
136}
137export declare type Maybe<T> = null | undefined | T;
138export interface GraphQLErrorsResult {
139 errors?: ReadonlyArray<{
140 message: string;
141 path?: Maybe<ReadonlyArray<string | number>>;
142 }>;
143}
144export interface SupergraphSDLFetcherOptions {
145 endpoint: string;
146 key: string;
147}
148export interface SchemaFetcherOptions {
149 endpoint: string;
150 key: string;
151}
152export interface ServicesFetcherOptions {
153 endpoint: string;
154 key: string;
155}