import { resolve } from "path" ; import { ApolloIntrospection , GraphQLIntrospection , Introspection , Schema , SchemaLoader } from "../interface" ; export interface IJsonSchemaLoaderOptions { schemaFile : string ; } export const jsonSchemaLoader = ( options ) => { try { const schemaPath = resolve ( options . schemaFile ) ; const introspection = require ( schemaPath ) ; const schema = ( introspection as ApolloIntrospection ) . __schema || ( introspection as GraphQLIntrospection ) . data . __schema ; return Promise . resolve ( schema ) ; } catch ( err ) { return Promise . reject ( err ) ; } } ;