Code Monkey home page Code Monkey logo

laravel-graphiql's People

Contributors

leonardocustodio avatar mfn avatar mostafa-rz avatar spawnia avatar themhv avatar yannick-bruening avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-graphiql's Issues

BadMethodCallException - Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist

I am currently encountering an issue with the MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath method. I'm receiving a BadMethodCallException with the message stating "Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist."

Steps to reproduce the issue:

  1. Install the latest version of the MLL\GraphiQL package.

Environment:

  • PHP Version: 8.2
  • Laravel Version: 10
  • MLL\GraphiQL Version: 3.1

Attempts to fix:

I attempted to clear the compiled class file and re-optimize the class loader by running artisan optimize, but the issue persisted.

GraphiQL is not defined

I got an error when trying to run GraphiQL.

Uncaught ReferenceError: GraphiQL is not defined

Investigando o código do repo me deparei com um erro no código do comando graphiql:download-assets:

file_put_contents($publicPath, $cdnPath);

The correct code is:

file_put_contents($publicPath, $contents);

"Persist headers" not working

Currently "Persist headers" does not persist the config after page refreshing. Any workarounds?

Tested on Chrome and Safari

image

I can see it toggles the variable on local storage, but after page refreshing it is gone.

image

Failed to load GraphiQl bug with plugin-explorer in version 1.21

When loading GraphiQL I get the following error in console:

"GraphiQLPluginExplorer is not defined"

Checking the vendor files, in src/DownloadAssetsCommand.php exactly on line 23:

public const EXPLORER_PLUGIN_PATH_CDN = '//unpkg.com/@graphiql/plugin-explorer/dist/graphiql-plugin-explorer.umd.js';

leads to version 1.21 of plugin-explorer, which is down, To solve it, I replaced that line with:

public const EXPLORER_PLUGIN_PATH_CDN = '//unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js';

I used version 1.20 and it worked but it is not the definitive solution.

graphiql-plugin-explorer.umd.js not found

Can't access /graphiql because:

Failed to load resource: the server responded with a status of 404 ()
https://unpkg.com/@graphiql/[email protected]/dist/graphiql-plugin-explorer.umd.js is return 404.

ReferenceError: GraphiQLPluginExplorer is not defined
    at GraphiQLWithExplorer (graphiql:70:17)

Probably has something to do with a new version v3.1?

Docs not being loaded

I am using Laravel Lighthouse. I just installed it today, and this package. Ever since installing I'm getting the error below:

{
  "errors": [
    {
      "message": "Failed to fetch",
      "stack": "TypeError: Failed to fetch\n    at http://unpkg.com/graphiql/graphiql.min.js:65084:22\n    at Generator.next (<anonymous>)\n    at http://unpkg.com/graphiql/graphiql.min.js:65003:67\n    at new Promise (<anonymous>)\n    at __webpack_modules__.../../graphiql-toolkit/esm/create-fetcher/lib.js.__awaiter (http://unpkg.com/graphiql/graphiql.min.js:64985:10)\n    at http://unpkg.com/graphiql/graphiql.min.js:65083:85\n    at http://unpkg.com/graphiql/graphiql.min.js:64912:54\n    at fetchIntrospectionData (http://unpkg.com/graphiql/graphiql.min.js:58264:40)\n    at http://unpkg.com/graphiql/graphiql.min.js:58286:39\n    at http://unpkg.com/graphiql/graphiql.min.js:58298:5"
    }
  ]
}

Is this an issue or have I set something up improperly? I'm using Laravel 9 with PHP 8.

Sanctum CSRF issue

I've followed the instructions for CSRF, and the token is being sent correctly on each request.
image

The web middleware is included in the graphiql config.

             'middleware' => ['web'],

Decoding the XSRF-TOKEN cookie matches the token that is being sent.

The web middleware group consists of the following middleware:

        [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ]

Though I'm still getting a 419 error. CSRF is working correctly from the frontend.

Any ideas?

Wrong function call

I received this msg: "Method MLL\GraphiQL\DownloadAssetsCommand::explorerPluginPath does not exist."

At DownloadAssetsCommand.php only exist "pluginExplorerPath"

I think it should be explorerPluginPath instead.

Set headers in new tabs

X-CSRF-TOKEN is set when GraphiQL is opened, but not when a new tab is opened.
If you reload the browser, a new tab will be created and X-CSRF-TOKEN will be set.

ScreenShot 2022-09-16 11 10 27

X-CSRF-TOKEN is set in Headers.

  • Add tab is pressed.

ScreenShot 2022-09-16 11 10 38

X-CSRF-TOKEN is not set.

  • ❌ Browser reload

ScreenShot 2022-09-16 13 52 14

A new tab is created, X-CSRF-TOKEN is set in Headers.
I don't want a new tab to be created when reloading the browser.

Please let me know if there is anything missing.

Environment

  • PHP: 8.1.10
  • Laravel: 9.27.0
  • mll-lab/laravel-graphiql: 1.0.0

Process

$ php artisan vendor:publish --tag=graphiql-view

Add to resources/views/vendor/graphiql/index.blade.php head

<head>
    <meta name="csrf-token" content="{{ csrf_token() }}">
</head>

Add to resources/views/vendor/graphiql/index.blade.php script

<script>
    ReactDOM.render(
        React.createElement(GraphiQL, {
            fetcher: GraphiQL.createFetcher({
                url: '{{ url(config('graphiql.endpoint')) }}',
                subscriptionUrl: '{{ config('graphiql.subscription-endpoint') }}',
            }),
            shouldPersistHeaders: true,
            headers: JSON.stringify({
                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
            }),
        }),
        document.getElementById('graphiql'),
    );
</script>

Add to config/graphiql.php route.middleware

    'route' => [
        'uri' => '/graphiql',
        'name' => 'graphiql',
        'middleware' => ['web'],
        // 'prefix' => '',
        // 'domain' => 'graphql.' . env('APP_DOMAIN', 'localhost'),
    ],
$ php artisan optimize:clear

How to add in a documentation Enums root type?

Is there any possibility to add some structure here? Or maybe it can be done somewhere else?
A screenshot shows a query and mutation, but it is harder to find enums in All Schema Types if a frontend dev is not sure what they need to find.
Of course if frontend and backend devs are working together and they always can make a deal that all of the enum types must have '_enum' or something in the name of enum, thus frontend dev could search it by this word ending, but what if frontend works alone and there is no backend dev to have a deal with?
image

Cannot subscribe to pusher based WS server

Hi,

I'm trying to integrate and test subscriptions with GraphiQL but I'm really struggling. When attempting to execute a subscription I get -

{
  "errors": [
    {
      "message": "Invalid message",
      "stack": "Error: Invalid message\n    at parseMessage (https://unpkg.com/graphiql/graphiql.min.js:20983:11)\n    at socket.onmessage (https://unpkg.com/graphiql/graphiql.min.js:20657:52)"
    }
  ]
}

When subscribing to a Pusher channel I get the following message back -

{"event":"pusher:connection_established","data":"{\"socket_id\":\"2814561052.459239379\",\"activity_timeout\":30}"}

This connection established response causes the error because it fails the isMessage check in graphiql.min.js as once converted to n object, it checks if there a property called type. Pusher doesn't have a type property and as such fails.

Can it be possible to just ignore Pusher system messages?

Thanks,
Chris.

Customization of GraphiQL UI view does not working

Hi all 👋

I have a problem with the comand
php artisan vendor:publish --tag=graphiql-view

Once the command was run, the index.blade.php file was successfully generated:
image

However any changes to the file are not applied. I also tried clearing the Laravel caches.

I need to change the Fetch call by adding an authentication parameter.
Do you have any ideas? 😢

Sanctum Authentication not working (with fix)

Hi, i followed sanctum instructions but it's not working for queries .

I added defaultHeaders to GraphiQLWithExplorer function. It gets the schema but it will throw CSRF error on queries.

To fix this problem i also added headers object to fetcher.

const fetcher = GraphiQL.createFetcher({
        url: '{{ $url }}',
        subscriptionUrl: '{{ $subscriptionUrl }}',
+        headers: {
+            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
+        },
    });

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.