Code Monkey home page Code Monkey logo

graphiql-middleware's Introduction

GraphiQL PSR-15 Middleware

Latest Version Software License

Add a GraphiQL interface to your application with this PSR-15 middleware.

This is basically a copy of graphiql-middleware adjusted for PSR-15.

Install

composer require dr-schopalopp/graphiql-middleware

Usage

This middleware was developed in a slim project, but it should work with any other PSR-15 compatible framework.

Slim 4

// app/dependencies.php

use DrSchopalopp\GraphiQLMiddleware\GraphiQLMiddleware;

return function (ContainerBuilder $containerBuilder) {
    $containerBuilder->addDefinitions([
        // ...
        
        GraphiQLMiddleware::class => function () {
            return new GraphiQLMiddleware();
        }
        
        // ...
    ]);
};
// app/middleware.php

use DrSchopalopp\GraphiQLMiddleware\GraphiQLMiddleware;

return function (App $app) {
    // ...
    
    $app->add(GraphiQLMiddleware::class);
    
    // ...
};
// app/routes.php

return static function (App $app) {
    // ...

    // dummy route necessary otherwise you will get an HTTP 405 Method Not Allowed error 
    $app->get('/graphiql', function (Request $request, Response $response) {
        return $response;
    });
    
    // ...
};

see HTTP 405 Method Not Allowed for details

License

The MIT License (MIT). Please see License File for more information.

graphiql-middleware's People

Contributors

dr-schopalopp avatar

Watchers

 avatar

graphiql-middleware's Issues

Catch HTTP 405 Method not allowed Error

HTTP 405 Method not allowed Error should be catched in GraphiQLMiddleware::process and delivery GraphiQL index.html instead. After this the dummy route isn't necessary anymore

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.