deno.land / x / pothos@release-1713397530 / packages / plugin-authz / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-nocheckimport './global-types.ts';import SchemaBuilder, { BasePlugin, PothosOutputFieldConfig, PothosTypeConfig, SchemaTypes, } from '../core/index.ts';export * from './types.ts';const pluginName = "authz";export class PothosAuthZPlugin<Types extends SchemaTypes> extends BasePlugin<Types> { override onOutputFieldConfig(fieldConfig: PothosOutputFieldConfig<Types>): PothosOutputFieldConfig<Types> | null { const { authz } = fieldConfig.pothosOptions; if (!authz) { return fieldConfig; } return { ...fieldConfig, extensions: { ...fieldConfig.extensions, authz: { directives: [ { name: "authz", arguments: authz, }, ], }, }, }; } override onTypeConfig(typeConfig: PothosTypeConfig): PothosTypeConfig { if ((typeConfig.graphqlKind !== "Object" && typeConfig.graphqlKind !== "Interface") || typeConfig.kind === "Query" || typeConfig.kind === "Mutation" || typeConfig.kind === "Subscription") { return typeConfig; } const { authz } = typeConfig.pothosOptions; if (!authz) { return typeConfig; } return { ...typeConfig, extensions: { ...typeConfig.extensions, authz: { directives: [ { name: "authz", arguments: authz, }, ], }, }, }; }}SchemaBuilder.registerPlugin(pluginName, PothosAuthZPlugin);export default pluginName;
pothos

Version Info

Tagged at
a year ago