UNPKG

polen

Version:

A framework for delightful GraphQL developer portals

135 lines 4.15 kB
/** * Layer 2: Schema Integration * * Bridge between GraphQL analysis and Polen's schema system. * Resolves identifiers against the actual schema, extracts documentation, * and generates reference URLs for navigation. */ import { type GraphQLSchema, type GraphQLType } from 'graphql'; import type { Identifier } from './types.js'; /** * Documentation extracted from GraphQL schema */ export interface Documentation { /** Description from schema SDL or introspection */ description?: string; /** Type signature (e.g., "String!", "[User!]!") */ typeInfo: string; /** Whether this field/type is deprecated */ deprecated?: { reason: string; replacement?: string; }; /** Default value for arguments */ defaultValue?: string; } /** * Result of resolving an identifier against the schema */ export interface SchemaResolution { /** Whether the identifier exists in the schema */ exists: boolean; /** Documentation extracted from schema */ documentation?: Documentation; /** URL to the reference page for this identifier */ referenceUrl: string; /** Whether this identifier is deprecated */ deprecated?: { reason: string; replacement?: string; }; /** The GraphQL type if this is a type identifier */ graphqlType?: GraphQLType; } /** * Interface for resolving GraphQL identifiers against a schema */ export interface SchemaResolver { /** * Resolve an identifier against the schema */ resolveIdentifier(identifier: Identifier): SchemaResolution | null; /** * Get documentation for a schema path */ getDocumentation(schemaPath: string[]): Documentation | null; /** * Generate a reference URL for a schema path */ generateReferenceLink(schemaPath: string[]): string; /** * Check if a type exists in the schema */ typeExists(typeName: string): boolean; /** * Get all available types for validation */ getAllTypes(): string[]; } /** * Configuration for URL generation */ export interface RouteConfig { /** Base path for reference pages (default: "/reference") */ basePath?: string; /** Whether to include fragments in URLs (default: true) */ includeFragments?: boolean; } /** * Polen's implementation of SchemaResolver */ export declare class PolenSchemaResolver implements SchemaResolver { private schema; private routeConfig; constructor(schema: GraphQLSchema, routeConfig?: RouteConfig); /** * Resolve an identifier against the schema */ resolveIdentifier(identifier: Identifier): SchemaResolution | null; /** * Get documentation for a schema path */ getDocumentation(schemaPath: string[]): Documentation | null; /** * Generate a reference URL for a schema path */ generateReferenceLink(schemaPath: string[]): string; /** * Check if a type exists in the schema */ typeExists(typeName: string): boolean; /** * Get all available types for validation */ getAllTypes(): string[]; private resolveType; private resolveField; private resolveArgument; private resolveDirective; private getFieldFromType; private getTypeSignature; } /** * Create a schema resolver for Polen */ export declare const createPolenSchemaResolver: (schema: GraphQLSchema, routeConfig?: RouteConfig) => SchemaResolver; /** * Enhanced analysis result with schema resolution */ export interface SchemaAwareAnalysisResult { /** Original analysis result */ analysis: import('./types.js').AnalysisResult; /** Schema resolutions for all identifiers */ resolutions: Map<string, SchemaResolution>; /** Validation errors from schema checking */ schemaErrors: { identifier: Identifier; message: string; severity: `error` | `warning`; }[]; } /** * Perform schema-aware analysis of a GraphQL document */ export declare const analyzeWithSchema: (source: string, schema: GraphQLSchema, routeConfig?: RouteConfig) => SchemaAwareAnalysisResult; //# sourceMappingURL=schema-integration.d.ts.map