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

Allow connectionParams to be Promise or async function #70

Closed
rpastro opened this issue Nov 12, 2020 · 4 comments · Fixed by #71
Closed

Allow connectionParams to be Promise or async function #70

rpastro opened this issue Nov 12, 2020 · 4 comments · Fixed by #71
Labels
enhancement New feature or request released Has been released and published

Comments

@rpastro
Copy link
Contributor

rpastro commented Nov 12, 2020

Currently the connectionParams option must be either a Record<string, unknown> or a synchronous function that returns Record<string, unknown>.

  /**
   * Optional parameters, passed through the `payload` field with the `ConnectionInit` message,
   * that the client specifies when establishing a connection with the server. You can use this
   * for securely passing arguments for authentication.
   */
  connectionParams?: Record<string, unknown> | (() => Record<string, unknown>);

This is an issue for applications that need to asynchronously retrieve the data for the ConnectionInit message. Like for instance retrieving a security token required for the WS authentication. This is particularly a problem in case lazy option is set to false and the client tries to open the WS immediately.

This is enhancement request to allow connectionParams to be either a Promise or async function, so the application can asynchronously retrieve the information required for the ConnectionInit message.

@enisdenjo
Copy link
Owner

Awesome! Makes total sense. PR incoming...

@rpastro
Copy link
Contributor Author

rpastro commented Nov 12, 2020

@enisdenjo When are you planning to release a new version of graphql-ws which includes the enhancements merged today?

@enisdenjo
Copy link
Owner

As soon as I close this issue.

@enisdenjo
Copy link
Owner

🎉 This issue has been resolved in version 1.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@enisdenjo enisdenjo added the released Has been released and published label Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released Has been released and published
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants