Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Context from graphql-server no longer carrying currentUser post 7.x.x #10101

Closed
1 task done
twodotsmax opened this issue Mar 3, 2024 · 4 comments
Closed
1 task done
Labels
bug/needs-info More information is needed for reproduction

Comments

@twodotsmax
Copy link
Contributor

What's not working?

This is new and wasn't addressed in the upgrade guide:

'"@redwoodjs/graphql-server"' has no exported member named 'context'. Did you mean 'Context'?

I have various redwood functions that need to pull user data, and it's typically done via:

import {
context as globalContext
} from '@redwoodjs/graphql-server'

const user = globalContext.currentUser

But now it fails with

TypeError: Cannot read properties of undefined (reading 'currentUser')

I think this may be related to #9371

How do we reproduce the bug?

yarn rw g function testContextNotWorking

import {
context as globalContext
} from '@redwoodjs/graphql-server'

Then in the function:

const user = globalContext.currentUser

This should cause it to crash

What's your environment? (If it applies)

System:
    OS: macOS 13.2.1
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /private/var/folders/_4/3_22xmqj3cs_yz7z6tbj1mh40000gn/T/xfs-470d61f3/node
    Yarn: 4.1.0 - /private/var/folders/_4/3_22xmqj3cs_yz7z6tbj1mh40000gn/T/xfs-470d61f3/yarn
  Databases:
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Chrome: 122.0.6261.94
    Edge: 122.0.2365.63
    Safari: 16.3
  npmPackages:
    @redwoodjs/auth-azure-active-directory-setup: 7.0.6 => 7.0.6
    @redwoodjs/core: 7.0.6 => 7.0.6

Are you interested in working on this?

  • I'm interested in working on this
@twodotsmax twodotsmax added the bug/needs-info More information is needed for reproduction label Mar 3, 2024
@twodotsmax twodotsmax changed the title [Bug?]: Context no longer carrying user post 7.x.x [Bug?]: Context from graphql-server no longer carrying currentUser post 7.x.x Mar 3, 2024
@twodotsmax
Copy link
Contributor Author

That fixes it, thanks Josh

@Josh-Walker-GM
Copy link
Collaborator

Thanks @twodotsmax! Sorry if we didn't list something breaking in the release notes.

We have a new package @redwoodjs/context which should export a context that you can use in place of the one originally from the graphql package. Are you able to confirm if making this switch works without any other changes to your code? I can clarify further if that isn't clear too. I hope we can clarify that the only change needed is the package and then we can update our docs. If other changes are needed then we should debug them here.

@Josh-Walker-GM
Copy link
Collaborator

Brilliant. I'll make a note to update our docs.

@johndevor
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction
Projects
None yet
Development

No branches or pull requests

3 participants