Comments (17)
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.
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.
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.
Update
Latest version of
graphiql
also now pass request headers asconnectionParams
. 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.
I guess what I'm really asking is: what is the best way to authenticate the user for subscriptions?
from pioneer.
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.
from pioneer.
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.
It's a bit more work to do that. I think I can still make the change though.
from pioneer.
This is definitely a bug on my part
from pioneer.
Awesome! I like that solution and I agree with you on your points
from pioneer.
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:
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.
However, it also have issues with not sending any other header with a key that is not the common header list.
from pioneer.
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.
Thanks for doing this so quickly! I guess I'm using Apollo Sandbox for now
from pioneer.
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.
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.
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)
- Public structs have no public initialisers
- After pausing the websocket connection from Apollo iOS, it can't reconnect. HOT 12
- Documentation search is pointing to incorrect path HOT 2
- Better typing for payload HOT 1
- Improvement to Test HOT 1
- Improvement to optional spec-compliant HOT 4
- Field Resolve Middleware HOT 1
- VaporMiddleware responding incorrectly to all paths HOT 7
- Plugins
- Error: 'ConcurrentResolve' is only available in macOS 12 or newer HOT 4
- TestConsumer Improvement
- subscription Precondition failed HOT 13
- Subscription via gateway HOT 3
- Improvement to spec-compliant HOT 1
- Value null in data on errors HOT 8
- GraphQL together with gRPC HOT 4
- Support for the new Swift Universal HTTP types
- Does Pioneer support multiplexing subscriptions over one WebSocket connection? HOT 6
- Does Pioneer support subscriptions via SSE? HOT 2
- `websocketOnInit` has not been implemented
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pioneer.