Skip to content

Commit

Permalink
Remove experimental plugin (connectrpc#178)
Browse files Browse the repository at this point in the history
`@tanstack/react-query` v5 is introducing some major changes to their
types and also introduce suspense specific APIs (useSuspenseQuery,
useSuspenseInfiniteQuery, and useSuspenseQueries). These APIs are pretty
easy to integrate with the original plugin (non-react specific) but
would need an additional two APIs generated for every service method.
This starts to create a lot of noise with our auto-complete options:

As an example, if we have a service method called `say`, we now must
generate `useSayQuery`, `useSayInfiniteQuery`, `useSayMutation`,
`useSaySuspenseQuery`, and `useSaySuspenseInfiniteQuery`. This is
increasingly making a lot of noise when just trying to use the `say`
method from a service. This is much worse with larger service method
names.

In keeping with best practices (limiting the number of ways to do a
single thing), we've decided to remove this plugin from the repo.
  • Loading branch information
paul-sachs authored Sep 29, 2023
1 parent 34b7169 commit ee30d41
Show file tree
Hide file tree
Showing 18 changed files with 0 additions and 1,748 deletions.
36 changes: 0 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,6 @@ Connect-query (along with all other javascript based connect packages) can be te

For playwright, you can see a sample test [here](https://github.com/connectrpc/connect-playwright-es/blob/main/packages/connect-playwright-example/tests/simple.spec.ts).

## Experimental plugin

There is an alternate plugin [`@connectrpc/protoc-gen-connect-query-react`](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query-react) that you can use if you are using `@tanstack/react-query` only (and is not compatible with other frameworks like Solid). This plugin is currently experimental to see if it provides a better developer experience.

```tsx
import { useExampleQuery } from "your-generated-code/example-ExampleService_connectquery_react";

export const Example: FC = () => {
const { data } = useExampleQuery({});
return <div>{data}</div>;
};
```

## Frequently Asked Questions

### How do I pass other TanStack Query options?
Expand Down Expand Up @@ -563,29 +550,6 @@ You can use Connect-Query with any TanStack variant (React, Solid, Svelte, Vue).

> Tip: If you're a TanStack Query user that uses something other than React, we'd love to hear from you. Please reach out to us on the [Buf Slack](https://buf.build/links/slack).
#### SolidJS Example

Say, for example, you're using Solid together with TanStack Query's `useQuery` API. In this case you can use `UnaryFunctions.createUseQueryOptions` instead of `UnaryHooks.useQuery`. The only difference is that `createUseQueryOptions` requires you to pass in a `Transport` because it is not a hook and hooks are where transport is automatically inferred.

Here's an example using SolidJS:

```tsx
import { createQuery } from "@tanstack/solid-query";
import { getTodos } from "./example-ElizaService_connectquery";

function Component() {
const options = example.createUseQueryOptions(
{ name: "My First Todo" },
{ transport },
);
const query = createQuery({
...options,
queryKey: () => options.queryKey,
});
return <div>{whatever}</div>;
}
```

### What about Streaming?

Connect-Query currently only supports Unary RPC methods, which use a simple request/response style of communication similar to GET or POST requests in REST. This is because it aligns most closely with TanStack Query's paradigms. However, we understand that there may be use cases for Server Streaming, Client Streaming, and Bidirectional Streaming, and we're eager to hear about them.
Expand Down
1 change: 0 additions & 1 deletion packages/protoc-gen-connect-query-react/.eslintignore

This file was deleted.

240 changes: 0 additions & 240 deletions packages/protoc-gen-connect-query-react/README.md

This file was deleted.

This file was deleted.

48 changes: 0 additions & 48 deletions packages/protoc-gen-connect-query-react/package.json

This file was deleted.

16 changes: 0 additions & 16 deletions packages/protoc-gen-connect-query-react/snapshots/buf.gen.yaml

This file was deleted.

Loading

0 comments on commit ee30d41

Please sign in to comment.