https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
support-questions
  • z

    ZeferiniX

    08/13/2021, 9:48 AM
    more context on our setup
    apollo-server-express
    is used as a middleware on the express app thanks to that, I can intercept the requests via middlewares and can make use of the node sdk if they go through plain http requests
  • r

    rp

    08/13/2021, 9:48 AM
    understood.
  • z

    ZeferiniX

    08/13/2021, 9:49 AM
    so that's all fine there, but for the graphql subscription server, it's separate
  • z

    ZeferiniX

    08/13/2021, 9:50 AM
    entirely outside the express app so I can't ride on express middlewares and in turn can't make use of supertokens' provided middlewares
  • z

    ZeferiniX

    08/13/2021, 9:50 AM
    thus my question of is there a way to get the session manually, but I can't get the
    res
    object which the sdk needs 🤷‍♂️
  • r

    rp

    08/13/2021, 9:51 AM
    So there must be a way that the socket connection is initiated right? Some HTTP request that starts the socket connection?
  • z

    ZeferiniX

    08/13/2021, 9:52 AM
    technically, yes there should be one
  • r

    rp

    08/13/2021, 9:52 AM
    and that would go through your express server?
  • z

    ZeferiniX

    08/13/2021, 9:53 AM
    no and I think that's the problem, the only way we can interface with that, to my knowledge based on what I've understood in the docs of
    subscriptions-transport-ws
    , is via the
    onConnect
  • r

    rp

    08/13/2021, 9:54 AM
    hmmmm
  • r

    rp

    08/13/2021, 9:54 AM
    so the
    onConnect
    is called as a result of a http request?
  • z

    ZeferiniX

    08/13/2021, 9:55 AM
    that I'm not quite sure how to verify 🤔
  • z

    ZeferiniX

    08/13/2021, 9:55 AM
    but it must be, right?
  • r

    rp

    08/13/2021, 9:55 AM
    yea.. it must be haha
  • r

    rp

    08/13/2021, 9:55 AM
    what's the structure of the context object?
  • z

    ZeferiniX

    08/13/2021, 10:01 AM
    it's pretty long, tried to trace the docs on what it uses but here:
    socket
    - the WebSocket object from the
    ws
    lib
  • z

    ZeferiniX

    08/13/2021, 10:01 AM
    and a
    request
    object of type
    IncomingMessage
    from the
    http
    lib 🤔
  • z

    ZeferiniX

    08/13/2021, 10:03 AM
    or wait, did you mean the
    context
    object on line 97?
  • r

    rp

    08/13/2021, 10:04 AM
    yes
  • z

    ZeferiniX

    08/13/2021, 10:05 AM
    oh, no, that's a custom typescript interface for the app's consumption
  • z

    ZeferiniX

    08/13/2021, 10:05 AM
    I created that one, graphql resolvers have a concept of
    context
    on every request
  • r

    rp

    08/13/2021, 10:10 AM
    hmm
  • r

    rp

    08/13/2021, 10:12 AM
    you are returning the context, which means the
    onConnect
    functions "understands" the type you have made? So my question here is, what is the return type of the
    onConnect
    function?
  • z

    ZeferiniX

    08/13/2021, 10:16 AM
    the return type doesn't really matter, what gets returned by this
    onConnect
    function becomes the graphql context object of the graphql subscription resolver
  • z

    ZeferiniX

    08/13/2021, 10:18 AM
    it could be anything, and in this case , it should be this type, but of course I don't want to supply
    req
    and
    res
    objects when working with graphql subscriptions, thus the
    Omit<T>
  • r

    rp

    08/13/2021, 10:18 AM
    ok. give me somtime.. i'll have to read more about this.
  • z

    ZeferiniX

    08/13/2021, 10:18 AM
    then again, these types are unreliable in this scenario, as I'm not exactly receiving an express
    req
    object
  • z

    ZeferiniX

    08/13/2021, 10:18 AM
    since the subscription server is entirely separate
  • r

    rp

    08/13/2021, 10:19 AM
    So another question: How is this server subscribed to in the first place?
  • z

    ZeferiniX

    08/13/2021, 10:19 AM
    via the
    http
Powered by Linen
Title
z

ZeferiniX

08/13/2021, 10:19 AM
via the
http
View count: 2