Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liammartens/fauna-x-schemas
https://github.com/liammartens/fauna-x-schemas
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/liammartens/fauna-x-schemas
- Owner: LiamMartens
- Created: 2023-09-05T17:41:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-20T14:37:26.000Z (over 1 year ago)
- Last Synced: 2024-11-20T19:41:45.388Z (about 1 month ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# fauna-x-schemas
This package can be used to apply validation to Fauna's new driver since they are moving away from GraphQL, it is now impossible to use the current codegen tooling.## Example usage
```js
import z from 'zod';
import { Client, fql } from 'fauna';
import { documentSchemaFactory } from 'fauna-x-schemas';// it is also possible to omit the collection name in which case zod will not check the collection type itself
const userSchema = documentSchemaFactory('User').merge(z.object({
username: z.string()
}));const client = new Client({
secret: '',
});// you can use the schema for validation or just for typing
const forceTyping = await client.query>(fql`User.byId("id")`);
const validated = userSchema.parse(
await client.query(fql`User.byId("id")`)
);
```