Giter VIP home page Giter VIP logo

Comments (17)

d-exclaimation avatar d-exclaimation commented on May 28, 2024 1

The difficult part is that connectionParams is loosely typed and many examples just put whatever on it. I am not really liking the approach of adding another parameter to the contextBuilder because now you have to check for the Request and the additional payload to get a header for instance. Not to mention that in the subscriptions portion of the application, the request query is not present inside the Request object.

I was considering having a seperate contextBuilder instead since now you will be provided with the payload, the query, and the arguments as well.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024 1

I have a somewhat of working solution with the seperate context builder but I have finals today so I'll make sure everything work properly and publish the new version later the day.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024 1

Technically, this library now properly support connectionParams from graphql-ws in 0.7.0, but since your original question involved GraphiQL which is still not capable to pass the request header into the connectionParams, I will keep this issue open until I can resolve that issue.

As of now, the only resolution I have is to opt for Apollo Sandbox to use graphql-ws that can pass request header into the connectionParams when making a websocket connection.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024 1

Update

Latest version of graphiql also now pass request headers as connectionParams . Although, I have to check whether everything work properly with the way it is setup.

In terms of default option for playground, both seemed like good choices now. I am considering Apollo Sandbox as the default option if both are working well. I will be closing this issue after I checked and fixed any issue with both IDEs

GraphiQL can send connectionParams for graphql-ws but not for subscriptions-transport-ws. To be fair, this is a non issue as subscriptions-transport-ws is considered legacy now, but this also meant the default IDE is likely going to be Apollo Sandbox instead of GraphiQL.

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

I guess what I'm really asking is: what is the best way to authenticate the user for subscriptions?

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

https://www.apollographql.com/docs/apollo-server/data/subscriptions#onconnect-and-ondisconnect

It sounds like the right thing to do is to take use the connectionParams that would get passed from the graphql client in the onConnect function. In GraphiQL my understanding is that it just passes the Request Headers as connectionParams.

Is this something that we could add support for in Pioneer? For a production environment authentication is important.

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

enisdenjo/graphql-ws#263

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

enisdenjo/graphql-ws#263 (comment)

This seems like the way to do it. I think all it involves is accepting a payload for ConnectionInit. That payload could then be passed to the contextBuilder as another parameter. Then the contextBuilder could implement the logic to see if it was getting the parameters from the request or the connectionParams.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

It's a bit more work to do that. I think I can still make the change though.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

This is definitely a bug on my part

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

Awesome! I like that solution and I agree with you on your points

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

I couldn't find anything on GraphiQL that will let it pass the request header given in the header tab into the connectionParams, and whether that is even possible.

This is websocket message sent by GraphiQL with some values in the header tab:
Screenshot 2022-06-18 at 4 50 49 PM

I am aware of passing it manually shown graphql/graphiql#2181 (comment). However, I couldn't any resolution to passing the request header tab values as connectionParams.

When using BananaCakePop which does sent the headers in the header tab into the connectionParams, I can verify that the changes made #41 does work.
Screenshot 2022-06-18 at 5 04 15 PM

However, it also have issues with not sending any other header with a key that is not the common header list.

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

I verified this does work with Apollo Sandbox, which was able to sent the request header specified in the header tab to the connectionParams which is received by the websocket context builder, so at the moment, this is a GraphiQL specific issue

from pioneer.

cshadek avatar cshadek commented on May 28, 2024

Thanks for doing this so quickly! I guess I'm using Apollo Sandbox for now

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

Update

Latest version of @apollo/sandbox now have supported subscriptions and seemed to meet feature parity with the cloud hosted version.

Whether there are still some issue with the self hosted one, I am not too sure. I will be spending some time looking into this and possibly update this library to have that as its default GraphQL IDE

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

Update

Latest version of graphiql also now pass request headers as connectionParams . Although, I have to check whether everything work properly with the way it is setup.

In terms of default option for playground, both seemed like good choices now. I am considering Apollo Sandbox as the default option if both are working well. I will be closing this issue after I checked and fixed any issue with both IDEs

from pioneer.

d-exclaimation avatar d-exclaimation commented on May 28, 2024

The default is changed now. Made sure both Apollo Sandbox and GraphiQL should be working properly using the latest version in v0.10.1.

Closing this issue for now, feel free to reopen an issue related come up

from pioneer.

Related Issues (20)

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.