Comments (4)
It seems this is an issue when I bounce the websocket link from the client side after I get a new login token and attempt to reconnect with the new token. If I don't send the authorization token at all, then the connection is made, though of course, I have an undefined user at the server side.
from apollo.
very interesting...if I send a token at all, I never get connected. If I send an empty token, websocket gets connected:
this code causes websocket to not connect:
const wsLink = new WebSocketLink({
uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
options: {
reconnect: true,
connectionParams: () => ( // a promise that resolves to return the loginToken
new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
getLoginToken().then(token => {
if (token) {
console.log("wsLink loginToken = " + token);
resolve({
[constants.AUTH_TOKEN_KEY]: token // if I set a token here, connection does not work!
});
} else {
resolve({
[constants.AUTH_TOKEN_KEY]: ""
});
}
}).catch(() => {
console.log("could not retrieve a login token!");
});
}))
}
});
Using an empty token gets the connection to go through:
const wsLink = new WebSocketLink({
uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
options: {
reconnect: true,
connectionParams: () => ( // a promise that resolves to return the loginToken
new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
getLoginToken().then(token => {
if (token) {
console.log("wsLink loginToken = " + token);
resolve({
[constants.AUTH_TOKEN_KEY]: "" // using an empty token gets it go through
});
} else {
resolve({
[constants.AUTH_TOKEN_KEY]: ""
});
}
}).catch(() => {
console.log("could not retrieve a login token!");
});
}))
}
});
from apollo.
This is almost certainly a server side issue, particularly with the meteor integration. If I set a header of "boo" instead of "meteor-login-token", the the connection goes through as well:
const wsLink = new WebSocketLink({
uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
options: {
reconnect: true,
connectionParams: () => ( // a promise that resolves to return the loginToken
new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
getLoginToken().then(token => {
if (token) {
console.log("wsLink loginToken = " + token);
resolve({
["boo"]: token // header is boo instead of meteor-login-token
});
} else {
resolve({
[constants.AUTH_TOKEN_KEY]: ""
});
}
}).catch(() => {
console.log("could not retrieve a login token!");
});
}))
}
});
from apollo.
I can reproduce this using graph-ql playground by setting a "meteor-login-token" HTTP header and doing a subscription query:
{"meteor-login-token": "boo"}
I get this error in playground:
{
"error": {
"message": "Cannot read property 'userDefaultFields' of undefined"
}
}
from apollo.
Related Issues (20)
- Authentication Directives HOT 1
- [Question] Fields resolved by external API HOT 6
- me query returns null HOT 6
- apollo db not work HOT 2
- [Question] How to expose links' metadata in schema HOT 1
- Shouldn't require resolvers for links. HOT 2
- Query lock-down on production
- Decouple Apollo Client to NPM
- Could I use this package for `Meteor + Vue`? HOT 2
- Get `userId = null`? HOT 1
- See what we can learn from here.
- Get the loader from cultofcoders:apollo
- Deep filtering
- `userId` is `undefined` in `matb33:collection-hooks` HOT 1
- Support Apollo Client 3.0
- test 2 p
- test 1 p
- test 1
- Project Management
- \ttest se tset
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 apollo.