UNPKG

@directus/api

Version:

Directus is a real-time API and App dashboard for managing SQL database content

33 lines (32 loc) 1.36 kB
import type { Accountability, Item, Query, SchemaOverview } from '@directus/types'; import type { FormattedExecutionResult, GraphQLSchema } from 'graphql'; import type { Knex } from 'knex'; import type { AbstractServiceOptions, GraphQLParams } from '../../types/index.js'; export type GQLScope = 'items' | 'system'; export declare class GraphQLService { accountability: Accountability | null; knex: Knex; schema: SchemaOverview; scope: GQLScope; constructor(options: AbstractServiceOptions & { scope: GQLScope; }); /** * Execute a GraphQL structure */ execute({ document, variables, operationName, contextValue, }: GraphQLParams): Promise<FormattedExecutionResult>; /** * Generate the GraphQL schema. Pulls from the schema information generated by the get-schema util. */ getSchema(): Promise<GraphQLSchema>; getSchema(type: 'schema'): Promise<GraphQLSchema>; getSchema(type: 'sdl'): Promise<GraphQLSchema | string>; /** * Execute the read action on the correct service. Checks for singleton as well. */ read(collection: string, query: Query): Promise<Partial<Item>>; /** * Upsert and read singleton item */ upsertSingleton(collection: string, body: Record<string, any> | Record<string, any>[], query: Query): Promise<Partial<Item> | boolean>; }