naystack 1.4.27 → 1.4.29
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/dist/graphql/index.cjs.js +49 -15
- package/dist/graphql/index.esm.js +49 -15
- package/dist/graphql/utils.cjs.js +49 -15
- package/dist/graphql/utils.d.mts +13 -11
- package/dist/graphql/utils.d.ts +13 -11
- package/dist/graphql/utils.esm.js +49 -15
- package/package.json +1 -1
|
@@ -664,6 +664,7 @@ async function initGraphQLServer({
|
|
|
664
664
|
|
|
665
665
|
// src/graphql/utils.ts
|
|
666
666
|
var import_headers2 = require("next/headers");
|
|
667
|
+
var import_react = require("react");
|
|
667
668
|
var import_type_graphql2 = require("type-graphql");
|
|
668
669
|
|
|
669
670
|
// src/auth/constants.ts
|
|
@@ -703,25 +704,58 @@ var getUserId = async () => {
|
|
|
703
704
|
return refresh ? getUserIdFromRefreshToken(refresh) : null;
|
|
704
705
|
};
|
|
705
706
|
function getAuthCaller(fn) {
|
|
706
|
-
return
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
707
|
+
return (0, import_react.cache)(
|
|
708
|
+
async (data) => {
|
|
709
|
+
const ctx = {
|
|
710
|
+
userId: await getUserId(),
|
|
711
|
+
isRefreshID: true
|
|
712
|
+
};
|
|
713
|
+
return await fn(ctx, data);
|
|
714
|
+
}
|
|
715
|
+
);
|
|
713
716
|
}
|
|
714
717
|
function getCaller(fn) {
|
|
715
|
-
return
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
718
|
+
return (0, import_react.cache)(
|
|
719
|
+
async (data) => {
|
|
720
|
+
const ctx = {
|
|
721
|
+
userId: null,
|
|
722
|
+
isRefreshID: true
|
|
723
|
+
};
|
|
724
|
+
return await fn(ctx, data);
|
|
725
|
+
}
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
function getFieldAuthCaller(fn) {
|
|
729
|
+
return (0, import_react.cache)(
|
|
730
|
+
async (root, data) => {
|
|
731
|
+
const ctx = {
|
|
732
|
+
userId: await getUserId(),
|
|
733
|
+
isRefreshID: true
|
|
734
|
+
};
|
|
735
|
+
return await fn(root, ctx, data);
|
|
736
|
+
}
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
function getFieldCaller(fn) {
|
|
740
|
+
return (0, import_react.cache)(
|
|
741
|
+
async (root, data) => {
|
|
742
|
+
const ctx = {
|
|
743
|
+
userId: null,
|
|
744
|
+
isRefreshID: true
|
|
745
|
+
};
|
|
746
|
+
return await fn(root, ctx, data);
|
|
747
|
+
}
|
|
748
|
+
);
|
|
722
749
|
}
|
|
723
750
|
function field(fn, options) {
|
|
724
|
-
return {
|
|
751
|
+
return {
|
|
752
|
+
...options,
|
|
753
|
+
fn,
|
|
754
|
+
authCall: getFieldAuthCaller(fn),
|
|
755
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
756
|
+
fn
|
|
757
|
+
)
|
|
758
|
+
};
|
|
725
759
|
}
|
|
726
760
|
function QueryLibrary(queries) {
|
|
727
761
|
let GeneratedResolver = class {
|
|
@@ -651,6 +651,7 @@ async function initGraphQLServer({
|
|
|
651
651
|
|
|
652
652
|
// src/graphql/utils.ts
|
|
653
653
|
import { cookies as cookies2 } from "next/headers";
|
|
654
|
+
import { cache } from "react";
|
|
654
655
|
import {
|
|
655
656
|
Arg,
|
|
656
657
|
Authorized,
|
|
@@ -699,25 +700,58 @@ var getUserId = async () => {
|
|
|
699
700
|
return refresh ? getUserIdFromRefreshToken(refresh) : null;
|
|
700
701
|
};
|
|
701
702
|
function getAuthCaller(fn) {
|
|
702
|
-
return
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
703
|
+
return cache(
|
|
704
|
+
async (data) => {
|
|
705
|
+
const ctx = {
|
|
706
|
+
userId: await getUserId(),
|
|
707
|
+
isRefreshID: true
|
|
708
|
+
};
|
|
709
|
+
return await fn(ctx, data);
|
|
710
|
+
}
|
|
711
|
+
);
|
|
709
712
|
}
|
|
710
713
|
function getCaller(fn) {
|
|
711
|
-
return
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
714
|
+
return cache(
|
|
715
|
+
async (data) => {
|
|
716
|
+
const ctx = {
|
|
717
|
+
userId: null,
|
|
718
|
+
isRefreshID: true
|
|
719
|
+
};
|
|
720
|
+
return await fn(ctx, data);
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
function getFieldAuthCaller(fn) {
|
|
725
|
+
return cache(
|
|
726
|
+
async (root, data) => {
|
|
727
|
+
const ctx = {
|
|
728
|
+
userId: await getUserId(),
|
|
729
|
+
isRefreshID: true
|
|
730
|
+
};
|
|
731
|
+
return await fn(root, ctx, data);
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
function getFieldCaller(fn) {
|
|
736
|
+
return cache(
|
|
737
|
+
async (root, data) => {
|
|
738
|
+
const ctx = {
|
|
739
|
+
userId: null,
|
|
740
|
+
isRefreshID: true
|
|
741
|
+
};
|
|
742
|
+
return await fn(root, ctx, data);
|
|
743
|
+
}
|
|
744
|
+
);
|
|
718
745
|
}
|
|
719
746
|
function field(fn, options) {
|
|
720
|
-
return {
|
|
747
|
+
return {
|
|
748
|
+
...options,
|
|
749
|
+
fn,
|
|
750
|
+
authCall: getFieldAuthCaller(fn),
|
|
751
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
752
|
+
fn
|
|
753
|
+
)
|
|
754
|
+
};
|
|
721
755
|
}
|
|
722
756
|
function QueryLibrary(queries) {
|
|
723
757
|
let GeneratedResolver = class {
|
|
@@ -35,6 +35,7 @@ __export(utils_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(utils_exports);
|
|
37
37
|
var import_headers2 = require("next/headers");
|
|
38
|
+
var import_react = require("react");
|
|
38
39
|
var import_type_graphql = require("type-graphql");
|
|
39
40
|
|
|
40
41
|
// src/auth/constants.ts
|
|
@@ -125,25 +126,58 @@ var getUserId = async () => {
|
|
|
125
126
|
return refresh ? getUserIdFromRefreshToken(refresh) : null;
|
|
126
127
|
};
|
|
127
128
|
function getAuthCaller(fn) {
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
129
|
+
return (0, import_react.cache)(
|
|
130
|
+
async (data) => {
|
|
131
|
+
const ctx = {
|
|
132
|
+
userId: await getUserId(),
|
|
133
|
+
isRefreshID: true
|
|
134
|
+
};
|
|
135
|
+
return await fn(ctx, data);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
135
138
|
}
|
|
136
139
|
function getCaller(fn) {
|
|
137
|
-
return
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
return (0, import_react.cache)(
|
|
141
|
+
async (data) => {
|
|
142
|
+
const ctx = {
|
|
143
|
+
userId: null,
|
|
144
|
+
isRefreshID: true
|
|
145
|
+
};
|
|
146
|
+
return await fn(ctx, data);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function getFieldAuthCaller(fn) {
|
|
151
|
+
return (0, import_react.cache)(
|
|
152
|
+
async (root, data) => {
|
|
153
|
+
const ctx = {
|
|
154
|
+
userId: await getUserId(),
|
|
155
|
+
isRefreshID: true
|
|
156
|
+
};
|
|
157
|
+
return await fn(root, ctx, data);
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
function getFieldCaller(fn) {
|
|
162
|
+
return (0, import_react.cache)(
|
|
163
|
+
async (root, data) => {
|
|
164
|
+
const ctx = {
|
|
165
|
+
userId: null,
|
|
166
|
+
isRefreshID: true
|
|
167
|
+
};
|
|
168
|
+
return await fn(root, ctx, data);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
144
171
|
}
|
|
145
172
|
function field(fn, options) {
|
|
146
|
-
return {
|
|
173
|
+
return {
|
|
174
|
+
...options,
|
|
175
|
+
fn,
|
|
176
|
+
authCall: getFieldAuthCaller(fn),
|
|
177
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
178
|
+
fn
|
|
179
|
+
)
|
|
180
|
+
};
|
|
147
181
|
}
|
|
148
182
|
function QueryLibrary(queries) {
|
|
149
183
|
let GeneratedResolver = class {
|
package/dist/graphql/utils.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
import { Query, Arg
|
|
2
|
+
import { ClassType, Query, Arg } from 'type-graphql';
|
|
3
3
|
import { AuthorizedContext, Context } from './types.mjs';
|
|
4
4
|
|
|
5
5
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
@@ -23,21 +23,23 @@ interface BaseDefinition<T, U, IsAuth extends boolean = false, OutputNullable ex
|
|
|
23
23
|
inputOptions?: NullableOptions<ArgsOptions, InputNullable>;
|
|
24
24
|
authorized?: IsAuth;
|
|
25
25
|
}
|
|
26
|
-
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
27
|
-
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
28
|
-
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
29
|
-
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
26
|
+
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
27
|
+
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
28
|
+
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
29
|
+
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
30
30
|
mutation?: boolean;
|
|
31
31
|
}
|
|
32
|
-
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
33
|
-
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
34
|
-
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
32
|
+
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>;
|
|
33
|
+
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
34
|
+
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
35
|
+
call: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
36
|
+
authCall: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
35
37
|
}
|
|
36
|
-
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
37
|
-
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any>>>(queries: T): {
|
|
38
|
+
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>;
|
|
39
|
+
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any, any>>>(queries: T): {
|
|
38
40
|
new (): {};
|
|
39
41
|
};
|
|
40
|
-
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any>>>(type: ClassType, queries: T): {
|
|
42
|
+
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>>>(type: ClassType, queries: T): {
|
|
41
43
|
new (): {};
|
|
42
44
|
};
|
|
43
45
|
|
package/dist/graphql/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLScalarType } from 'graphql';
|
|
2
|
-
import { Query, Arg
|
|
2
|
+
import { ClassType, Query, Arg } from 'type-graphql';
|
|
3
3
|
import { AuthorizedContext, Context } from './types.js';
|
|
4
4
|
|
|
5
5
|
type ReturnOptions = Parameters<typeof Query>[1];
|
|
@@ -23,21 +23,23 @@ interface BaseDefinition<T, U, IsAuth extends boolean = false, OutputNullable ex
|
|
|
23
23
|
inputOptions?: NullableOptions<ArgsOptions, InputNullable>;
|
|
24
24
|
authorized?: IsAuth;
|
|
25
25
|
}
|
|
26
|
-
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
27
|
-
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
28
|
-
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
29
|
-
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
26
|
+
interface QueryDefinition<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
27
|
+
fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
28
|
+
call: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
29
|
+
authCall: (data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
30
30
|
mutation?: boolean;
|
|
31
31
|
}
|
|
32
|
-
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
33
|
-
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
34
|
-
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) =>
|
|
32
|
+
declare function query<T, U, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): QueryDefinition<T, U, IsAuth, OutputNullable, InputNullable, R>;
|
|
33
|
+
interface FieldResolverDefinition<T, U, Root, IsAuth extends boolean = false, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>> extends BaseDefinition<T, U, IsAuth, OutputNullable, InputNullable> {
|
|
34
|
+
fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R;
|
|
35
|
+
call: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
36
|
+
authCall: (root: Root, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => Promise<Awaited<R>>;
|
|
35
37
|
}
|
|
36
|
-
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false
|
|
37
|
-
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any>>>(queries: T): {
|
|
38
|
+
declare function field<T, U, IsAuth extends boolean, Root, OutputNullable extends boolean = false, InputNullable extends boolean = false, R extends Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>> = Promisify<ParsedGQLTypeWithNullability<T, OutputNullable, true>>>(fn: (root: Root, ctx: IsAuth extends true ? AuthorizedContext : Context, data: ParsedGQLTypeWithNullability<U, InputNullable, false>) => R, options: Omit<FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>, "fn" | "authCall" | "call">): FieldResolverDefinition<T, U, Root, IsAuth, OutputNullable, InputNullable, R>;
|
|
39
|
+
declare function QueryLibrary<T extends Record<string, QueryDefinition<any, any, any, any, any, any>>>(queries: T): {
|
|
38
40
|
new (): {};
|
|
39
41
|
};
|
|
40
|
-
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any>>>(type: ClassType, queries: T): {
|
|
42
|
+
declare function FieldLibrary<X extends object, T extends Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>> = Record<string, FieldResolverDefinition<any, any, X, any, any, any, any>>>(type: ClassType, queries: T): {
|
|
41
43
|
new (): {};
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -11,6 +11,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
11
|
|
|
12
12
|
// src/graphql/utils.ts
|
|
13
13
|
import { cookies as cookies2 } from "next/headers";
|
|
14
|
+
import { cache } from "react";
|
|
14
15
|
import {
|
|
15
16
|
Arg,
|
|
16
17
|
Authorized,
|
|
@@ -110,25 +111,58 @@ var getUserId = async () => {
|
|
|
110
111
|
return refresh ? getUserIdFromRefreshToken(refresh) : null;
|
|
111
112
|
};
|
|
112
113
|
function getAuthCaller(fn) {
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
return cache(
|
|
115
|
+
async (data) => {
|
|
116
|
+
const ctx = {
|
|
117
|
+
userId: await getUserId(),
|
|
118
|
+
isRefreshID: true
|
|
119
|
+
};
|
|
120
|
+
return await fn(ctx, data);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
120
123
|
}
|
|
121
124
|
function getCaller(fn) {
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
return cache(
|
|
126
|
+
async (data) => {
|
|
127
|
+
const ctx = {
|
|
128
|
+
userId: null,
|
|
129
|
+
isRefreshID: true
|
|
130
|
+
};
|
|
131
|
+
return await fn(ctx, data);
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function getFieldAuthCaller(fn) {
|
|
136
|
+
return cache(
|
|
137
|
+
async (root, data) => {
|
|
138
|
+
const ctx = {
|
|
139
|
+
userId: await getUserId(),
|
|
140
|
+
isRefreshID: true
|
|
141
|
+
};
|
|
142
|
+
return await fn(root, ctx, data);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function getFieldCaller(fn) {
|
|
147
|
+
return cache(
|
|
148
|
+
async (root, data) => {
|
|
149
|
+
const ctx = {
|
|
150
|
+
userId: null,
|
|
151
|
+
isRefreshID: true
|
|
152
|
+
};
|
|
153
|
+
return await fn(root, ctx, data);
|
|
154
|
+
}
|
|
155
|
+
);
|
|
129
156
|
}
|
|
130
157
|
function field(fn, options) {
|
|
131
|
-
return {
|
|
158
|
+
return {
|
|
159
|
+
...options,
|
|
160
|
+
fn,
|
|
161
|
+
authCall: getFieldAuthCaller(fn),
|
|
162
|
+
call: options.authorized ? getFieldAuthCaller(fn) : getFieldCaller(
|
|
163
|
+
fn
|
|
164
|
+
)
|
|
165
|
+
};
|
|
132
166
|
}
|
|
133
167
|
function QueryLibrary(queries) {
|
|
134
168
|
let GeneratedResolver = class {
|