deno.land / x / pothos@release-1713397530 / packages / plugin-authz / index.ts
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556// @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;
Version Info