asma-helpers 0.8.2 → 0.8.3
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/package.json
CHANGED
|
@@ -16,13 +16,13 @@ interface CliOptions extends Omit<ClientOptions, 'url' | 'signal'> {
|
|
|
16
16
|
}
|
|
17
17
|
/* @__PURE__ */
|
|
18
18
|
export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
19
|
-
|
|
19
|
+
setReqConfig,
|
|
20
20
|
createClient,
|
|
21
21
|
service,
|
|
22
22
|
//serviceUrl,
|
|
23
23
|
path = '/v1/graphql',
|
|
24
24
|
}: {
|
|
25
|
-
|
|
25
|
+
setReqConfig?: () => Promise<{ headers: Record<string, string> }>
|
|
26
26
|
createClient: (options?: ClientOptions | undefined) => T
|
|
27
27
|
//serviceUrl?: () => string
|
|
28
28
|
service: keyof IEnvironmentUrlsGenQLOnly
|
|
@@ -87,6 +87,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
87
87
|
}
|
|
88
88
|
return service_url
|
|
89
89
|
}
|
|
90
|
+
const reqConf = setReqConfig || setReqConfigInternal
|
|
90
91
|
|
|
91
92
|
async function genqlClient(options: CliOptions & { abortController?: AbortController } = {}): Promise<T> {
|
|
92
93
|
const { headers, abortController: abortControlleFromOpts, ...rest } = options
|
|
@@ -100,9 +101,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
100
101
|
return createClient({
|
|
101
102
|
url: `${serviceUrlFn()}${path}`,
|
|
102
103
|
headers: async () => ({
|
|
103
|
-
...(options.anonymous
|
|
104
|
-
? {}
|
|
105
|
-
: (((await setReqConfigInternal()).headers ?? {}) as Record<string, string>)),
|
|
104
|
+
...(options.anonymous ? {} : (((await reqConf()).headers ?? {}) as Record<string, string>)),
|
|
106
105
|
...headers,
|
|
107
106
|
}),
|
|
108
107
|
signal: abortControllerlocal.signal,
|
|
@@ -123,7 +122,7 @@ export function generateGenqlClient<T extends ReturnType<typeof createClient>>({
|
|
|
123
122
|
subscription: {
|
|
124
123
|
reconnect: true,
|
|
125
124
|
reconnectionAttempts: 5,
|
|
126
|
-
headers: async () => ((await
|
|
125
|
+
headers: async () => ((await reqConf()).headers ?? {}) as Record<string, string>,
|
|
127
126
|
},
|
|
128
127
|
})
|
|
129
128
|
}
|