UNPKG

graphql-to-sparql

Version:
37 lines (36 loc) 1.48 kB
import type * as RDF from '@rdfjs/types'; import type { Algebra } from '@traqula/algebra-transformations-1-2'; import type { ValueNode } from 'graphql'; import type { IConvertContext } from '../../IConvertContext'; import type { IConvertSettings } from '../../IConvertSettings'; import type { Util } from '../../Util'; /** * A handler for converting GraphQL value nodes to terms and patterns. */ export declare abstract class NodeValueHandlerAdapter<T extends ValueNode> { readonly targetKind: string; protected readonly util: Util; protected readonly settings: IConvertSettings; constructor(targetKind: T['kind'], util: Util, settings: IConvertSettings); /** * Get the terms and patterns for the given value node. * @param {T} valueNode A GraphQL node. * @param {string} fieldName The name of the field or argument in which the value was encapsulated. * @param {IConvertContext} convertContext A conversion context. * @return {IValueNodeHandlerOutput} The RDF terms and patterns. */ abstract handle(valueNode: T, fieldName: string, convertContext: IConvertContext): IValueNodeHandlerOutput; } /** * The output of converting a value node to an RDF term. */ export interface IValueNodeHandlerOutput { /** * The resulting RDF terms. */ terms: RDF.Term[]; /** * An optional array of patterns that are dependencies of the resulting term(s). */ auxiliaryPatterns?: Algebra.Pattern[]; }