Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"scripts": {
"clean": "rimraf dist *.tsbuildinfo",
"prebuild": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json",
"test": "jest"
"test": "jest",
"test:watch": "jest --watch"
},
"devDependencies": {
"@tanstack/query-core": "^4.36.1",
Expand Down
51 changes: 51 additions & 0 deletions packages/react-query/src/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,41 @@ const api = stl.api({
}),
},
}),
multiplePathParams: stl.resource({
summary: "multiParam",
actions: {
retrieve: stl.endpoint({
endpoint: "GET /multiplePathParams/{foo}/{bar}",
path: z.object({ foo: z.string(), bar: z.number() }),
response: z.any(),
async handler() {},
}),
},
}),
nestedResource: stl.resource({
summary: "parent",
actions: {
retrieve: stl.endpoint({
endpoint: "GET /resource/{parentId}",
path: z.object({ parentId: z.string() }),
response: z.any(),
async handler() {},
}),
},
namespacedResources: {
subResource: stl.resource({
summary: "subResource",
actions: {
retrieve: stl.endpoint({
endpoint: "GET /resource/{parentId}/subResource/{childId}",
path: z.object({ parentId: z.string(), childId: z.string() }),
response: z.any(),
async handler() {},
}),
},
}),
},
}),
},
});

Expand Down Expand Up @@ -110,6 +145,22 @@ describe("useQuery methods", () => {
(client) => client.pathOptionalQuery.useRetrieve("a"),
"/pathOptionalQuery/a",
],
[
"get with multiple path params",
(client) => client.multiplePathParams.useRetrieve("foo", "bar"),
"/multiplePathParams/foo/bar",
],
[
"get nested namespaced resource parent",
(client) => client.nestedResource.useRetrieve("parent"),
"/resource/parent",
],
[
"get nested namespaced resource child",
(client) =>
client.nestedResource.subResource.useRetrieve("parent", "child"),
"/resource/parent/subResource/child",
],
] as [
string,
(client: StainlessReactQueryClient<typeof api>) => UseQueryResult<any>,
Expand Down
3 changes: 2 additions & 1 deletion packages/stainless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"scripts": {
"clean": "rimraf dist *.tsbuildinfo",
"prebuild": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json",
"test": "jest"
"test": "jest",
"test:watch": "jest --watch"
},
"devDependencies": {
"@types/jest": "^29.5.10",
Expand Down