Appwrite Graphql library, utilizing @tanstack/react-query and inspired by react-appwrite
npm install @zeroin.earth/appwrite-graphqlThis is a GraphQL library for Appwrite, built with the power of @tanstack/react-query and inspired by react-appwrite.
``bash
npm install --save @zeroin.earth/appwrite-graphql
yarn add @zeroin.earth/appwrite-graphql
`
:`js
/ Endpoint - Pick one /
APPWRITE_ENDPOINT=
NEXT_PUBLIC_APPWRITE_URL=
EXPO_PUBLIC_APPWRITE_URL=/ Project ID - Pick one /
APPWRITE_PROJECT_ID=
NEXT_PUBLIC_APPWRITE_PROJECT_ID
EXPO_PUBLIC_APPWRITE_PROJECT_ID
`$3
If you need to provide a custom endpoint and project ID, and can't use one of the above environment variables, you may override the default variables using the :`jsx
`$3
`jsx
import { useLogin } from "@zeroin.earth/appwrite-graphql";export function LogIn() {
const router = useRouter();
const { login, oAuthLogin } = useLogin();
const onSubmit: SubmitHandler = async (data) => {
await login.mutateAsync(data, {
onSuccess: () => {
router.push("/profile");
},
});
};
const loginWithGoogle = () => {
oAuthLogin.mutate({
provider: "google",
success: 'successUrl',
failure: 'failureUrl',
});
};
}
``jsx
import { useFunction } from "@zeroin.earth/appwrite-graphql";export function Form() {
const { executeFunction } = useFunction();
const onSubmit: SubmitHandler = async (data) => {
executeFunction.mutate(
{
functionId: '6gibhbyy6tggdf',
body: {
message: {
...data,
},
},
},
{
onSettled: () => {
setJustSignedUp(true);
},
},
);
};
}
`$3
`jsx
import {
fragments,
getFragmentData,
useAccount,
} from "@zeroin.earth/appwrite-graphql";export function Profile() {
const { data, isLoading } = useAccount({});
const account = getFragmentData(fragments.Account_UserFragment, data);
return (
{data && (
{Welcome, ${account?.name ?? "Visitor"}!}
)}
);
}
``We are working on matching parity with the current Appwrite SDK. After we do so, version numbers will match the currently supported version of the SDK. Until then, please feel free to use what we have finished so far!
Still left to do:
- [ ] List teams
- [ ] Create team
- [ ] Get team
- [ ] Update name
- [ ] Delete team
- [ ] List team memberships
- [ ] Create team membership
- [ ] Get team membership
- [ ] Update membership
- [ ] Delete team membership
- [ ] Update team membership status
- [ ] Get team preferences
- [ ] Update preferences
Done
- [X] List documents
- [X] Create document
- [X] Get document
- [x] Update document
- [x] Delete document
- [ ] List files
- [ ] Create file
- [ ] Get file
- [ ] Update file
- [ ] Delete File
- [ ] Get file for download
- [ ] Get file preview
- [ ] Get file for view
Done
- [X] Create execution
- [X] Get execution
- [ ] Get user locale
- [ ] List Locale Codes
- [ ] List continents
- [ ] List countries
- [ ] List EU countries
- [ ] List countries phone codes
- [ ] List currencies
- [ ] List languages
- [ ] Get browser icon
- [ ] Get credit card icon
- [ ] Get favicon
- [ ] Get country flag
- [ ] Get image from URL
- [ ] Get user initials
- [ ] Get QR code