is there someone here who got authorization workin...
# prisma-whats-new
r
is there someone here who got authorization working with WebsocketLink in Apollo 2.0 and getting the token from asyncStorage in react-native?
👍 1
m
Copy code
import { setContext } from "apollo-link-context";

import { ApolloLink, split ,from } from 'apollo-client-preset'

const httpLink = new HttpLink({ uri: 'SIMPE_ENDPOINT_URL' })

const authMiddleware = new setContext(operation => {
  AsyncStorage.getItem("token").then(token => {
    return {
      headers: {
        Authorization: `Bearer: ${token}` || null
      }
    };
  });
});



const client = new ApolloClient({
  link: from([authMiddleware, httpLink]),
  cache: new InMemoryCache()
})
r
where do you add the websocketlink
m
oh! this implementation doesnt have websocket. please disregard.
r
no problem 🙂 thanks tho
Is there really no one who has an example of this?
p
The info in this link:https://github.com/Akryum/vue-apollo/issues/144 combined with mimica's answer
should give you what you want