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

(fix) - use Record over object type for subscription operation variables #1119

Merged
merged 2 commits into from
Nov 5, 2020
Merged

(fix) - use Record over object type for subscription operation variables #1119

merged 2 commits into from
Nov 5, 2020

Conversation

enisdenjo
Copy link
Contributor

@enisdenjo enisdenjo commented Nov 5, 2020

As suggested by TS and recommended ESLint rules - don't use object as a type. The object type is currently hard to use (see this issue).

This also solves the type compatibility for graphql-ws where you can use the lib in TS as you would in plain ol' JS like in #1118.

Previously, because of this object type, you have to do this:

...
subscriptionExchange({
  forwardSubscription({ query, variables }) {
    return {
      subscribe: (sink) => {
        const dispose = wsClient.subscribe(
          {
            query,
            variables: variables as Record<string, unknown>, // 😞
          },
          sink,
        );

        return {
          unsubscribe: dispose,
        };
      },
    };
  },
}),
...

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2020

🦋 Changeset detected

Latest commit: d3c43a8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@urql/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

enisdenjo added a commit to enisdenjo/graphql-ws that referenced this pull request Nov 5, 2020
Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Would you mind running yarn changeset, marking this as a patch for core and adding a little explainer as to why this change is needed?

changesets are our way to automatically generate changelogs.

@enisdenjo
Copy link
Contributor Author

Awesome! Is this what you had in mind?

@JoviDeCroock
Copy link
Collaborator

That looks great @enisdenjo, thank you!

@kitten kitten merged commit 9e9b5ca into urql-graphql:main Nov 5, 2020
This was referenced Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants