{"id":15788127,"url":"https://github.com/ecyrbe/zodios-solid","last_synced_at":"2025-04-30T15:49:44.658Z","repository":{"id":60146936,"uuid":"540943174","full_name":"ecyrbe/zodios-solid","owner":"ecyrbe","description":"Solid hooks for zodios","archived":false,"fork":false,"pushed_at":"2024-10-23T15:15:03.000Z","size":1061,"stargazers_count":4,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-24T21:53:53.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ecyrbe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-24T19:24:19.000Z","updated_at":"2024-01-12T20:14:17.000Z","dependencies_parsed_at":"2023-02-16T17:05:23.639Z","dependency_job_id":"cebab76e-5bb7-4bec-adad-ea8731b350cd","html_url":"https://github.com/ecyrbe/zodios-solid","commit_stats":{"total_commits":235,"total_committers":2,"mean_commits":117.5,"dds":"0.15319148936170213","last_synced_commit":"9a0c7b58064f8b27284e77fe1c16cee714504ebe"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecyrbe%2Fzodios-solid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecyrbe%2Fzodios-solid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecyrbe%2Fzodios-solid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecyrbe%2Fzodios-solid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecyrbe","download_url":"https://codeload.github.com/ecyrbe/zodios-solid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246355249,"owners_count":20763973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T21:41:07.679Z","updated_at":"2025-03-31T15:31:02.677Z","avatar_url":"https://github.com/ecyrbe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":" \u003ch1 align=\"center\"\u003eZodios Solid\u003c/h1\u003e\n \u003cp align=\"center\"\u003e\n   \u003ca href=\"https://github.com/ecyrbe/zodios-solid\"\u003e\n     \u003cimg align=\"center\" src=\"https://raw.githubusercontent.com/ecyrbe/zodios-solid/main/docs/logo.svg\" width=\"128px\" alt=\"Zodios logo\"\u003e\n   \u003c/a\u003e\n \u003c/p\u003e\n \n \u003cp align=\"center\"\u003e\n    Solid hooks for zodios backed by \u003ca src=\"https://tanstack.com/query/v4/docs/adapters/solid-query\" \u003esolid-query\u003c/a\u003e\n \u003c/p\u003e\n \n \u003cp align=\"center\"\u003e\n   \u003ca href=\"https://www.npmjs.com/package/@zodios/solid\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/@zodios/solid.svg\" alt=\"langue typescript\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://www.npmjs.com/package/@zodios/solid\"\u003e\n   \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/dw/@zodios/solid\"\u003e\n   \u003c/a\u003e\n   \u003ca href=\"https://github.com/ecyrbe/zodios-solid/blob/main/LICENSE\"\u003e\n    \u003cimg alt=\"GitHub\" src=\"https://img.shields.io/github/license/ecyrbe/zodios-solid\"\u003e   \n   \u003c/a\u003e\n   \u003cimg alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/workflow/status/ecyrbe/zodios-solid/CI\"\u003e\n \u003c/p\u003e\n\n# Install\n\n```bash\n\u003e npm install @zodios/solid\n```\n\nor\n\n```bash\n\u003e yarn add @zodios/solid\n```\n\n# Usage\n\nZodios comes with a Query and Mutation hook helper.  \nIt's a thin wrapper around Solid-Query but with zodios auto completion.\n  \nZodios query hook also returns an invalidation helper to allow you to reset react query cache easily\n  \n```typescript\nimport { createSignal, For, Match, Show, Switch } from \"solid-js\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/solid-query\";\nimport { makeApi, Zodios } from \"@zodios/core\";\nimport { ZodiosHooks } from \"../src\";\nimport { z } from \"zod\";\n\n// you can define schema before declaring the API to get back the type\nconst userSchema = z\n  .object({\n    id: z.number(),\n    name: z.string(),\n  })\n  .required();\n\nconst createUserSchema = z\n  .object({\n    name: z.string(),\n  })\n  .required();\n\nconst usersSchema = z.array(userSchema);\n\n// you can then get back the types\ntype User = z.infer\u003ctypeof userSchema\u003e;\ntype Users = z.infer\u003ctypeof usersSchema\u003e;\n\nconst api = makeApi([\n  {\n    method: \"get\",\n    path: \"/users\",\n    alias: \"getUsers\",\n    description: \"Get all users\",\n    parameters: [\n      {\n        name: \"page\",\n        type: \"Query\",\n        schema: z.number().positive().optional(),\n      },\n      {\n        name: \"limit\",\n        type: \"Query\",\n        schema: z.number().positive().optional(),\n      },\n    ],\n    response: usersSchema,\n  },\n  {\n    method: \"get\",\n    path: \"/users/:id\",\n    description: \"Get a user\",\n    response: userSchema,\n  },\n  {\n    method: \"post\",\n    path: \"/users\",\n    alias: \"createUser\",\n    description: \"Create a user\",\n    parameters: [\n      {\n        name: \"body\",\n        type: \"Body\",\n        schema: createUserSchema,\n      },\n    ],\n    response: userSchema,\n  },\n]);\nconst baseUrl = \"https://jsonplaceholder.typicode.com\";\n\nconst zodios = new Zodios(baseUrl, api);\nconst zodiosHooks = new ZodiosHooks(\"jsonplaceholder\", zodios);\n\nconst Users = () =\u003e {\n  const [page, setPage] = createSignal(0);\n  const users = zodiosHooks.createInfiniteQuery(\n    \"/users\",\n    { queries: { limit: 10 } },\n    {\n      getPageParamList: () =\u003e {\n        return [\"page\"];\n      },\n      getNextPageParam: () =\u003e {\n        return {\n          queries: {\n            get page() {\n              return page() + 1;\n            },\n          },\n        };\n      },\n    }\n  );\n  const user = zodiosHooks.createCreateUser(undefined, {\n    onSuccess: () =\u003e users.invalidate(),\n  });\n\n  return (\n    \u003c\u003e\n      \u003cbutton onClick={() =\u003e user.mutate({ name: \"john\" })}\u003ecreate user\u003c/button\u003e\n      \u003cShow when={users.hasNextPage}\u003e\n        \u003cbutton onClick={() =\u003e users.fetchNextPage()}\u003enext\u003c/button\u003e\n      \u003c/Show\u003e\n      \u003cSwitch\u003e\n        \u003cMatch when={users.isLoading}\u003eLoading...\u003c/Match\u003e\n        \u003cMatch when={users.isFetchingNextPage}\u003eFetching...\u003c/Match\u003e\n        \u003cMatch when={!users.isFetching}\u003e\n          \u003cul\u003e\n            \u003cFor each={users.data?.pages}\u003e\n              {(user) =\u003e (\n                \u003cFor each={user}\u003e{(user) =\u003e \u003cli\u003e{user.name}\u003c/li\u003e}\u003c/For\u003e\n              )}\n            \u003c/For\u003e\n          \u003c/ul\u003e\n        \u003c/Match\u003e\n      \u003c/Switch\u003e\n    \u003c/\u003e\n  );\n};\n\n// on another file\nconst queryClient = new QueryClient();\n\nexport const App = () =\u003e {\n  return (\n    \u003cQueryClientProvider client={queryClient}\u003e\n      \u003cUsers /\u003e\n    \u003c/QueryClientProvider\u003e\n  );\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecyrbe%2Fzodios-solid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecyrbe%2Fzodios-solid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecyrbe%2Fzodios-solid/lists"}