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

Add executeExchange for using an executable schema #474

Merged
merged 21 commits into from
May 7, 2020
Merged

Conversation

andyrichardson
Copy link
Contributor

About

Exchange for executing queries locally using an executable schema.

This may be particularly useful for us when making example projects as we could mock responses here rather than implementing a server.

@andyrichardson andyrichardson added feature 🚀 future 🔮 An enhancement or feature proposal that will be addressed after the next release labels Nov 21, 2019
@kitten
Copy link
Member

kitten commented Nov 21, 2019

I think @mxstbr is already maintaining a package for that. We may just want to send a PR to update it a little https://github.com/mxstbr/urql-exchange-schema

@mxstbr
Copy link
Contributor

mxstbr commented Nov 21, 2019

Happy to merge that into core!

@andyrichardson
Copy link
Contributor Author

Let me know what you want to do 👍

@kitten kitten removed the future 🔮 An enhancement or feature proposal that will be addressed after the next release label Jan 20, 2020
@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2020

💥 No Changeset

Latest commit: 91100da

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@kitten
Copy link
Member

kitten commented Mar 12, 2020

@JoviDeCroock @andyrichardson assuming we'll want to get this merged soon, but we'll only need some minor documentation for this after a rebase, and let's stick it into a new exchanges/execute package?

@andyrichardson
Copy link
Contributor Author

@kitten Yeah I'm happy to sort that out but you're going to have to explain the monorepo to me.

The exchange is 61 lines, no new dependencies, and will be tree shaken if not in use. Do we want this exchange to be a standalone package in /exchanges?

Also, where do the docs for standalone packages go?

@kitten
Copy link
Member

kitten commented Mar 12, 2020

I think bundling an exchange would only make sense if a majority of users use it? Although, I can totally see an exchange being "moved" into core, when it crosses that threshold. For now, I'd play it safe. It looks like when execute is bundled (be that because it's bundled accidentally, or tree-shaking fails, or not an option, etc) it adds a lot of heft: apollographql/apollo-link#968

I've got some docs in the CONTRIBUTING.md guide that should help 👍 but happy to also pair on that or sth 👍 https://github.com/FormidableLabs/urql/blob/master/CONTRIBUTING.md#how-do-i-add-a-new-package

@andyrichardson
Copy link
Contributor Author

@kitten thanks for the explanation - I've moved it to /exchanges

exchanges/execute/package.json Outdated Show resolved Hide resolved
exchanges/execute/package.json Outdated Show resolved Hide resolved
exchanges/execute/src/execute.test.ts Outdated Show resolved Hide resolved
exchanges/execute/src/execute.ts Outdated Show resolved Hide resolved
exchanges/execute/src/execute.ts Outdated Show resolved Hide resolved
exchanges/execute/src/execute.ts Outdated Show resolved Hide resolved
@leebenson
Copy link

FWIW, this exchange fixed an issue I was experiencing with https://github.com/mxstbr/urql-exchange-schema, in that queries via SSR were being executed once for each exchange.

So a typical set-up of:

exchanges: [
  dedupExchange,
  cacheExchange,
  ssr,
  schemaExchange(schema, { context }),
]

... would actually run the query four times.

This is a subtle bug that's easy to overlook, since the first query that's run is the one that winds up being rendered back to the client.

Just a heads-up @mxstbr in case it made sense to update your own package while waiting for this to merge.

@kitten
Copy link
Member

kitten commented Apr 30, 2020

To get this up-to-date we just need to make sure that the config files match (package.json fields, some are linted by the prepare script), tsconfig.json changes, creating an empty CHANGELOG, etc

@amyboyd amyboyd self-assigned this May 4, 2020
@amyboyd
Copy link
Contributor

amyboyd commented May 7, 2020

To get this up-to-date we just need to make sure that the config files match (package.json fields, some are linted by the prepare script), tsconfig.json changes, creating an empty CHANGELOG, etc

The branch has been rebased on master and these files are matching the other extensions.

A few other misc changes -- see commit log.

@amyboyd amyboyd force-pushed the execute-exchange branch from 3e3449d to 4ed0c80 Compare May 7, 2020 05:39
exchanges/execute/README.md Outdated Show resolved Hide resolved
@kitten kitten merged commit be2c8da into master May 7, 2020
@kitten kitten deleted the execute-exchange branch May 7, 2020 12:06
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.

6 participants