Skip to content

Commit

Permalink
Update all packages to use the @connectrpc scope (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Aug 21, 2023
1 parent 8ce54d2 commit 89126d0
Show file tree
Hide file tree
Showing 45 changed files with 201 additions and 197 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- omit in toc -->
# Connect-Query

[![License](https://img.shields.io/github/license/connectrpc/connect-query-es?color=blue)](./LICENSE) [![Build](https://github.com/connectrpc/connect-query-es/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/connectrpc/connect-query-es/actions/workflows/ci.yaml) [![NPM Version](https://img.shields.io/npm/v/@bufbuild/connect-query/latest?color=green&label=%40bufbuild%2Fconnect-query)](https://www.npmjs.com/package/@bufbuild/connect-query) [![NPM Version](https://img.shields.io/npm/v/@bufbuild/protoc-gen-connect-query/latest?color=green&label=%40bufbuild%2Fprotoc-gen-connect-query)](https://www.npmjs.com/package/@bufbuild/protoc-gen-connect-query)
[![License](https://img.shields.io/github/license/connectrpc/connect-query-es?color=blue)](./LICENSE) [![Build](https://github.com/connectrpc/connect-query-es/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/connectrpc/connect-query-es/actions/workflows/ci.yaml) [![NPM Version](https://img.shields.io/npm/v/@connectrpc/connect-query/latest?color=green&label=%40connectrpc%2Fconnect-query)](https://www.npmjs.com/package/@connectrpc/connect-query) [![NPM Version](https://img.shields.io/npm/v/@connectrpc/protoc-gen-connect-query/latest?color=green&label=%40connectrpc%2Fprotoc-gen-connect-query)](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query)

Connect-Query is an expansion pack for [TanStack Query](https://tanstack.com/query) (react-query), written in TypeScript and thoroughly tested. It enables effortless communication with servers that speak the [Connect Protocol](https://connectrpc.com/docs/protocol).

Expand Down Expand Up @@ -45,10 +45,10 @@ Connect-Query is an expansion pack for [TanStack Query](https://tanstack.com/que
### Install

```sh
npm install @bufbuild/connect-query
npm install @connectrpc/connect-query
```

Note: If you are using something that doesn't automatically install peerDependencies (npm older than v7), you'll want to make sure you also have `@bufbuild/protobuf` and `@bufbuild/connect` installed.
Note: If you are using something that doesn't automatically install peerDependencies (npm older than v7), you'll want to make sure you also have `@bufbuild/protobuf` and `@connectrpc/connect` installed.

### Usage

Expand Down Expand Up @@ -94,7 +94,7 @@ One of the best features of this library is that once you write your schema in P
This example shows the best developer experience using code generation. Here's what that generated code looks like:

```ts title="your-generated-code/example-ExampleService_connectquery"
import { createQueryService } from "@bufbuild/connect-query";
import { createQueryService } from "@connectrpc/connect-query";
import { MethodKind } from "@bufbuild/protobuf";
import { ExampleRequest, ExampleResponse } from "./example_pb.js";

Expand Down Expand Up @@ -133,9 +133,9 @@ const createQueryService: <Service extends ServiceType>({
`createQueryService` is the main entrypoint for Connect-Query.
Pass in a service and you will receive an object with properties for each of your services and values that provide hooks for those services that you can then give to Tanstack Query. The `ServiceType` TypeScript interface is provided by Protobuf-ES (`@bufbuild/protobuf`) while generated service definitions are provided by Connect-Web (`@bufbuild/connect-web`).
Pass in a service and you will receive an object with properties for each of your services and values that provide hooks for those services that you can then give to Tanstack Query. The `ServiceType` TypeScript interface is provided by Protobuf-ES (`@bufbuild/protobuf`) while generated service definitions are provided by Connect-Web (`@connectrpc/connect-web`).
`Transport` refers to the mechanism by which your client will make the actual network calls. If you want to use a custom transport, you can optionally provide one with a call to `useTransport`, which Connect-Query exports. Otherwise, the default transport from React context will be used. This default transport is placed on React context by the `TransportProvider`. Whether you pass a custom transport or you use `TransportProvider`, in both cases you'll need to use one of `@bufbuild/connect-web`'s exports `createConnectTransport` or `createGrpcWebTransport`.
`Transport` refers to the mechanism by which your client will make the actual network calls. If you want to use a custom transport, you can optionally provide one with a call to `useTransport`, which Connect-Query exports. Otherwise, the default transport from React context will be used. This default transport is placed on React context by the `TransportProvider`. Whether you pass a custom transport or you use `TransportProvider`, in both cases you'll need to use one of `@connectrpc/connect-web`'s exports `createConnectTransport` or `createGrpcWebTransport`.
Note that the most memory performant approach is to use the transport on React Context by using the `TransportProvider` because that provider is memoized by React, but also that any calls to `createQueryService` with the same service is cached by this function.
Expand Down Expand Up @@ -180,11 +180,11 @@ With these two pieces of information in hand, the transport provides the critica

To learn more about the two modes of transport, take a look at the Connect-Web documentation on [choosing a protocol](https://connectrpc.com/docs/web/choosing-a-protocol/).

To get started with Connect-Query, simply import a transport (either [`createConnectTransport`](https://github.com/connectrpc/connect-es/blob/main/packages/connect-web/src/connect-transport.ts) or [`createGrpcWebTransport`](https://github.com/connectrpc/connect-es/blob/main/packages/connect-web/src/grpc-web-transport.ts) from [`@bufbuild/connect-web`](https://www.npmjs.com/package/@bufbuild/connect-web)) and pass it to the provider.
To get started with Connect-Query, simply import a transport (either [`createConnectTransport`](https://github.com/connectrpc/connect-es/blob/main/packages/connect-web/src/connect-transport.ts) or [`createGrpcWebTransport`](https://github.com/connectrpc/connect-es/blob/main/packages/connect-web/src/grpc-web-transport.ts) from [`@connectrpc/connect-web`](https://www.npmjs.com/package/@connectrpc/connect-web)) and pass it to the provider.

```tsx
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { TransportProvider } from "@bufbuild/connect-query";
import { TransportProvider } from "@connectrpc/connect-query";

const queryClient = new QueryClient();

Expand Down Expand Up @@ -419,7 +419,7 @@ For example, a partial query key might look like this:

## Experimental plugin

There is an alternate plugin [`@bufbuild/protoc-gen-connect-query-react`](https://www.npmjs.com/package/@bufbuild/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.
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';
Expand Down
10 changes: 5 additions & 5 deletions examples/react/basic-without-generation/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bufbuild/connect-query-example-react-basic-without-generation",
"name": "@connectrpc/connect-query-example-react-basic-without-generation",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -9,11 +9,11 @@
"preview": "vite preview"
},
"dependencies": {
"@bufbuild/connect-query": "workspace:*",
"@bufbuild/connect-web": "^0.12.0",
"@connectrpc/connect-query": "workspace:*",
"@connectrpc/connect-web": "^0.13.1",
"@bufbuild/protobuf": "^1.3.0",
"@bufbuild/protoc-gen-connect-es": "^0.12.0",
"@bufbuild/protoc-gen-connect-query": "workspace:*",
"@connectrpc/protoc-gen-connect-es": "^0.13.1",
"@connectrpc/protoc-gen-connect-query": "workspace:*",
"@bufbuild/protoc-gen-es": "^1.3.0",
"@tanstack/react-query": "^4.32.6",
"@tanstack/react-query-devtools": "^4.32.6",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/basic-without-generation/src/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { createQueryService } from '@bufbuild/connect-query';
import { createQueryService } from '@connectrpc/connect-query';
import { useQuery } from '@tanstack/react-query';
import { ElizaService } from 'generated-react/dist/eliza_connect';
import type { FC } from 'react';
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-without-generation/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import './index.css';

import { TransportProvider } from '@bufbuild/connect-query';
import { createConnectTransport } from '@bufbuild/connect-web';
import { TransportProvider } from '@connectrpc/connect-query';
import { createConnectTransport } from '@connectrpc/connect-web';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import * as ReactDOM from 'react-dom/client';
Expand Down
10 changes: 5 additions & 5 deletions examples/react/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bufbuild/connect-query-example-react-basic",
"name": "@connectrpc/connect-query-example-react-basic",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -9,11 +9,11 @@
"preview": "vite preview"
},
"dependencies": {
"@bufbuild/connect-query": "workspace:*",
"@bufbuild/connect-web": "^0.12.0",
"@connectrpc/connect-query": "workspace:*",
"@connectrpc/connect-web": "^0.13.1",
"@bufbuild/protobuf": "^1.3.0",
"@bufbuild/protoc-gen-connect-es": "^0.12.0",
"@bufbuild/protoc-gen-connect-query": "workspace:*",
"@connectrpc/protoc-gen-connect-es": "^0.13.1",
"@connectrpc/protoc-gen-connect-query": "workspace:*",
"@bufbuild/protoc-gen-es": "^1.3.0",
"@tanstack/react-query": "^4.32.6",
"@tanstack/react-query-devtools": "^4.32.6",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import './index.css';

import { TransportProvider } from '@bufbuild/connect-query';
import { createConnectTransport } from '@bufbuild/connect-web';
import { TransportProvider } from '@connectrpc/connect-query';
import { createConnectTransport } from '@connectrpc/connect-web';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import * as ReactDOM from 'react-dom/client';
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-query/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @bufbuild/connect-query
# @connectrpc/connect-query

This is the runtime library package for Connect-Query. You'll find its code generator at [@bufbuild/protoc-gen-connect-query](https://www.npmjs.com/package/@bufbuild/protoc-gen-connect-query).
This is the runtime library package for Connect-Query. You'll find its code generator at [@connectrpc/protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query).

Connect-Query is an expansion pack for [TanStack Query](https://tanstack.com/query) (react-query), written in TypeScript and thoroughly tested. It enables effortless communication with servers that speak the [Connect Protocol](https://connectrpc.com/docs/protocol).

Expand Down
8 changes: 4 additions & 4 deletions packages/connect-query/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bufbuild/connect-query",
"name": "@connectrpc/connect-query",
"version": "0.4.1",
"license": "Apache-2.0",
"sideEffects": false,
Expand Down Expand Up @@ -28,8 +28,8 @@
"test": "jest"
},
"devDependencies": {
"@bufbuild/connect": "^0.12.0",
"@bufbuild/connect-web": "^0.12.0",
"@connectrpc/connect": "^0.13.1",
"@connectrpc/connect-web": "^0.13.1",
"@bufbuild/protobuf": "^1.3.0",
"@bufbuild/protoc-gen-es": "^1.3.0",
"@tanstack/react-query": "^4.32.6",
Expand All @@ -44,7 +44,7 @@
"typescript": "^5.1.6"
},
"peerDependencies": {
"@bufbuild/connect": ">=0.12.0",
"@connectrpc/connect": ">=0.12.0",
"@bufbuild/protobuf": ">=1.3.0",
"@tanstack/react-query": "^4.20.4",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-query/src/create-query-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type { Transport } from '@bufbuild/connect';
import type {
Message,
MethodInfo,
MethodInfoUnary,
ServiceType,
} from '@bufbuild/protobuf';
import { MethodKind } from '@bufbuild/protobuf';
import type { Transport } from '@connectrpc/connect';

import type { UnaryHooks } from './unary-hooks';
import { unaryHooks } from './unary-hooks';
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-query/src/create-query-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type { Transport } from '@bufbuild/connect';
import type { ServiceType } from '@bufbuild/protobuf';
import type { Transport } from '@connectrpc/connect';

import type { QueryHooks } from './create-query-hooks';
import { createQueryHooks } from './create-query-hooks';
Expand All @@ -23,9 +23,9 @@ const servicesToHooks = new Map<ServiceType, QueryHooks<ServiceType>>();
/**
* `createQueryService` is the main entrypoint for Connect-Query.
*
* Pass in a service and you will receive an object with properties for each of your services and values that provide hooks for those services that you can then give to Tanstack Query. The `ServiceType` TypeScript interface is provided by Protobuf-ES (`@bufbuild/protobuf`) while generated service definitions are provided by Connect-Web (`@bufbuild/connect-web`).
* Pass in a service and you will receive an object with properties for each of your services and values that provide hooks for those services that you can then give to Tanstack Query. The `ServiceType` TypeScript interface is provided by Protobuf-ES (`@bufbuild/protobuf`) while generated service definitions are provided by Connect-Web (`@connectrpc/connect-web`).
*
* `Transport` refers to the mechanism by which your client will make the actual network calls. If you want to use a custom transport, you can optionally provide one with a call to `useTransport`, which Connect-Query exports. Otherwise, the default transport from React context will be used. This default transport is placed on React context by the `TransportProvider`. Whether you pass a custom transport or you use `TransportProvider`, in both cases you'll need to use one of `@bufbuild/connect-web`'s exports `createConnectTransport` or `createGrpcWebTransport`.
* `Transport` refers to the mechanism by which your client will make the actual network calls. If you want to use a custom transport, you can optionally provide one with a call to `useTransport`, which Connect-Query exports. Otherwise, the default transport from React context will be used. This default transport is placed on React context by the `TransportProvider`. Whether you pass a custom transport or you use `TransportProvider`, in both cases you'll need to use one of `@connectrpc/connect-web`'s exports `createConnectTransport` or `createGrpcWebTransport`.
*
* Note that the most memory performant approach is to use the transport on React Context by using the `TransportProvider` because that provider is memoized by React, but also that any calls to `createQueryService` with the same service is cached by this function.
*
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-query/src/jest/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type { CallOptions } from '@bufbuild/connect';
import { createRouterTransport } from '@bufbuild/connect';
import { createConnectTransport } from '@bufbuild/connect-web';
import type { PartialMessage } from '@bufbuild/protobuf';
import type { CallOptions } from '@connectrpc/connect';
import { createRouterTransport } from '@connectrpc/connect';
import { createConnectTransport } from '@connectrpc/connect-web';
import type { QueryClientConfig } from '@tanstack/react-query';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-query/src/unary-hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type { CallOptions, ConnectError, Transport } from '@bufbuild/connect';
import type {
Message,
MethodInfoUnary,
PartialMessage,
} from '@bufbuild/protobuf';
import { MethodKind } from '@bufbuild/protobuf';
import type { CallOptions, ConnectError, Transport } from '@connectrpc/connect';
import {
afterAll,
beforeEach,
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-query/src/unary-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import type { CallOptions, ConnectError, Transport } from '@bufbuild/connect';
import type {
Message,
MethodInfoUnary,
PartialMessage,
ServiceType,
} from '@bufbuild/protobuf';
import type { CallOptions, ConnectError, Transport } from '@connectrpc/connect';
import type {
GetNextPageParamFunction,
QueryFunctionContext,
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-query/src/use-transport.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { ConnectError } from '@bufbuild/connect';
import { ConnectError } from '@connectrpc/connect';
import { describe, expect, it } from '@jest/globals';
import { useQuery } from '@tanstack/react-query';
import { renderHook } from '@testing-library/react';
Expand All @@ -24,7 +24,7 @@ import { unaryHooks } from './unary-hooks';
import { fallbackTransport } from './use-transport';

const error = new ConnectError(
"To use Connect, you must provide a `Transport`: a simple object that handles `unary` and `stream` requests. `Transport` objects can easily be created by using `@bufbuild/connect-web`'s exports `createConnectTransport` and `createGrpcWebTransport`. see: https://connectrpc.com/docs/web/getting-started for more info.",
"To use Connect, you must provide a `Transport`: a simple object that handles `unary` and `stream` requests. `Transport` objects can easily be created by using `@connectrpc/connect-web`'s exports `createConnectTransport` and `createGrpcWebTransport`. see: https://connectrpc.com/docs/web/getting-started for more info.",
);

describe('fallbackTransport', () => {
Expand Down
Loading

0 comments on commit 89126d0

Please sign in to comment.