xaddax/webonxy-middleware

This package is abandoned and no longer maintained. The author suggests using the zestic/webonxy-middleware package instead.

Webonxy GraqhQL middleware

v0.6.0 2021-11-14 04:41 UTC

This package is auto-updated.

Last update: 2021-11-14 04:42:32 UTC


README

To use the middleware in Laminas Mezzio, configure the factories

in config/autoload/dependencies.global.php

return [
    'dependencies' => [
        'factories'  => [
            \GraphQL\Server\StandardServer::class => \Xaddax\GraphQL\Factory\StandardServerFactory::class,
            \Zestic\GraphQL\Middleware\GraphQLMiddleware::class => \Xaddax\GraphQL\Factory\GraphQLMiddlewareFactory::class,
        ],
    ],
];

Add configuration in config/autoload/graphql.global.php

return [
    'graphQL' => [
        'middleware' => [
            'allowedHeaders' => [
                'application/graphql',
                'application/json',
            ],
        ],
        'schema' => \Path\To\Schema::class, // optional, defaults to webonxy Schema
        'schemaConfig' => [], // optional, if not configured expected in Schema class constructor
        'server' => \Path\To\Server::class, // not yet implemented, defaults to webonxy StandardServer
        'serverConfig' => [

        ],
    ],
];

see the WebOnyx Server Configuration Documentation for the full options for the server config.

You'll need to set up the route. In config/routes.php

return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
    $app->post('/graphql', \Zestic\GraphQL\Middleware\GraphQLMiddleware::class, 'graphql');
};