import { createHandler } from "@webiny/handler" ; import handlerArgsPlugins from "@webiny/handler-args" ; import handlerHTTPPlugins from "@webiny/handler-http" ; import graphqlServerPlugins from "../src" ; export default ( { debug = false , plugins = [ ] } = { } ) => { const handler = createHandler ( handlerArgsPlugins ( ) , handlerHTTPPlugins ( ) , graphqlServerPlugins ( { debug } ) , ... plugins ) ; const invoke = async ( { method = "POST" , body , headers = { } , ... rest } ) => { const response = await handler ( { method , headers , body : JSON . stringify ( body ) , ... rest } ) ; return [ JSON . parse ( response . body ) , response ] ; } ; return { handler , invoke , async introspect ( ) { return invoke ( { body : { query : INTROSPECTION } } ) ; } } ; } ; const INTROSPECTION = `
    {
        __schema {
            types {
                name
                fields {
                    name
                    type {
                        name
                        kind
                        ofType {
                            name
                            kind
                        }
                    }
                }
            }
        }
    }
` ;