TypeScript-first expansion pack for TanStack Query that gives you Protobuf superpowers.
APACHE-2.0 License
Bot releases are visible (Hide)
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.3.0...v1.3.1
Published by paul-sachs 8 months ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.2.0...v1.3.0
Published by paul-sachs 9 months ago
With https://github.com/connectrpc/connect-query-es/pull/334, we're fixing a bug where the cache of a regular query collides with the cache of an infinite query, which can lead to type mismatches and unexpected failures if you use the same RPC with an infinite query and a regular query.
We are now using a separate query key for infinite queries to solve the issue (we append "infinite" to the key), but this change can potentially affect you:
If you tried to invalidate some infinite queries like queryClient.invalidateQueries({ queryKey: createConnectQueryKey(...), exact: true })
, this now only invalidates queries initialized with useQuery
. To invalidate infinite queries, you can either set exact
to false, or use createConnectInfiniteQueryKey()
instead. Also note that this change not only affects invalidateQueries
but any operations against the queryClient that interact with the cache using a key (eg, queryClient.setQueriesData, etc.)
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.1.3...v1.2.0
Published by paul-sachs 10 months ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.1.2...v1.1.3
Published by paul-sachs 10 months ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.1.1...v1.1.2
Published by paul-sachs 10 months ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.1.0...v1.1.1
Published by paul-sachs 10 months ago
By default, protoc-gen-connect-query (and all other plugins based on @bufbuild/protoplugin) generate ECMAScript import
and export
statements. For use cases where CommonJS is difficult to avoid, a new plugin option has been added named js_import_style
which can be used to generate CommonJS require()
calls.
Here is an example buf.gen.yaml:
version: v1
plugins:
# You'll need @bufbuild/protoc-gen-es v1.6.0 or later
- plugin: es
out: src/gen
opt: js_import_style=legacy_commonjs
- plugin: protoc-gen-connect-query
out: src/gen
opt: js_import_style=legacy_commonjs
To view the full PR, see Added support for cjs output by @paul-sachs in https://github.com/connectrpc/connect-query-es/pull/303
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v1.0.0...v1.1.0
Published by paul-sachs 11 months ago
Introducing a whole new API for connect-query. This API ties itself more tightly with the fantastic @tanstack/react-query
in order to improve developer experience and reduce bundle size.
At the core of this change is the new MethodUnaryDescriptor
type, which is essentially just a self contained description of a service method. The new code generator just outputs one of these per method and those are passed to the hooks/methods. This new additional type brings a huge level of flexibility about how we write additional methods, and it's trivial to write your own hooks/methods around these simple types.
import { useQuery } from "@connectrpc/connect-query";
import { say } from "./gen/eliza-ElizaService_connectquery";
...
const { data } = useQuery(say);
use*Query
hooks now return data instead of just options.create*
methods have been removed.protoc-gen-connect-query
now outputs very simple method descriptors instead of a bunch of hooks per method.There are a number of reasons we've decided to make this major breaking change.
@tanstack/react-query@5
provides better usage of Suspense versions of the API.The migration process is easy but manual:
import { getUserOrganization } from "@apigen/org/alpha/registry/v1alpha1/organization-OrganizationService_connectquery";
import { useQuery } from "@tanstack/react-query";
...
const getUserOrganizationQuery = useQuery({
...getUserOrganization.useQuery({
userId: currentUser?.id,
organizationId,
}),
useErrorBoundary: false,
enabled: currentUser !== null,
});
import { getUserOrganization } from "@apigen/org/alpha/registry/v1alpha1/organization-OrganizationService_connectquery";
import { useQuery } from "@connectrpc/connect-query";
...
const getUserOrganizationQuery = useQuery(getUserOrganization, {
userId: currentUser?.id,
organizationId,
},
{
useErrorBoundary: false,
enabled: currentUser !== null
}
});
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.6.0...v1.0.0
Published by paul-sachs 12 months ago
This update contains some breaking changes including, but not limited to:
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.5.3...v0.6.0
Published by paul-sachs about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.5.2...v0.5.3
Published by paul-sachs about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.5.1...v0.5.2
Published by paul-sachs about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.4.4...v0.5.1
@connectrpc/connect-query
UnaryHooks
type and replaced with UnaryFunctionsWithHooks
createUnaryHooks
to only return the hooks and not other functionsIntroduced createUnaryFunctions
which can be used with the new createUnaryHooks
to do the same thing as the old createUnaryHooks
. The reasoning behind this change is to prep the core library, connect-query
, to be able to used separately from React itself and this is just the first step in that direction.
protoc-gen-connect-query
and protoc-gen-connect-query-react
Each service method now generates two new functions associated to the method:
This method creates options that will pass to useInfiniteQuery
. It is identical to method.useInfiniteQuery
except it needs to be passed a transport directly.
This method creates options that will pass to useMutation
. It is identical to method.useMutation
except it needs to be passed a transport directly.
We added these methods to better future-proof the code for incoming changes to React (React Server Components, etc).
UnaryHooks
with UnaryFunctionsWithHooks
createUnaryHooks
and use a combination of createUnaryHooks
and createUnaryFunctions
Before
const say = createUnaryHooks(ExampleService);
After
const say = {
...createUnaryHooks(ExampleService),
...createUnaryFunctions(ExampleService),
}
Published by paul-sachs about 1 year ago
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.4.3...v0.4.4
Published by paul-sachs about 1 year ago
Exported serviced type allows you to directly use service with createRouterTransport
from @connectrpc/connect
with the exported service:
import { createRouterTransport } from "@connectrpc/connect";
import { ElizaService } from "./gen/eliza-ElizaService_connectquery";
...
const transport = createRouterTransport(({ service }) => {
service(ElizaService, {
say: () => ({
sentence: "Hello, world!",
}),
});
});
For more details, see example test here.
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.4.2...v0.4.3
Published by paul-sachs about 1 year ago
To keep Connect well-maintained and responsive to its users' needs over the long term, we're preparing to donate it to a foundation. (More details on that soon!) To cleanly separate Connect from Buf's other code, we're moving development to the connectrpc GitHub organization and to the connectrpc organization on npmjs.com.
This is the first release that publishes packages with the new @connectrpc
scope. To make the switch seamless, we are introducing a small tool that updates all references in your project automatically, @connectrpc/connect-migrate.
The switch is as simple as running a single command:
$ npx @connectrpc/connect-migrate@latest
Scanning... â
1 package.json file
1 lock file
5 source files
Updating source files...
src/client.ts â
src/server.ts â
src/webclient.ts â
Updating packages... â
package.json â
Updating lock file...
package-lock.json â
Old package | New package |
---|---|
@bufbuild/connect v0.13.0 | @connectrpc/connect v0.13.1 |
@bufbuild/connect-web v0.13.0 | @connectrpc/connect-web v0.13.1 |
@bufbuild/connect-fastify v0.13.0 | @connectrpc/connect-fastify v0.13.1 |
@bufbuild/connect-node v0.13.0 | @connectrpc/connect-node v0.13.1 |
@bufbuild/connect-next v0.13.0 | @connectrpc/connect-next v0.13.1 |
@bufbuild/connect-express v0.13.0 | @connectrpc/connect-express v0.13.1 |
@bufbuild/protoc-gen-connect-es v0.13.0 | @connectrpc/protoc-gen-connect-es v0.13.1 |
@bufbuild/connect-query v0.4.1 | @connectrpc/connect-query v0.4.2 |
@bufbuild/protoc-gen-connect-query v0.4.1 | @connectrpc/protoc-gen-connect-query v0.4.2 |
@bufbuild/protoc-gen-connect-query-react v0.4.1 | @connectrpc/protoc-gen-connect-query-react v0.4.2 |
Full Changelog: https://github.com/connectrpc/connect-query-es/compare/v0.4.1...v0.4.2
Published by paul-sachs about 1 year ago
Full Changelog: https://github.com/bufbuild/connect-query/compare/v0.4.0...v0.4.1