-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* doc: (#519) adding examples for getStaticPaths * Update API Router auth import docs * Update API Router imports to use `@faustjs/core/api` * Breakout Hooks into individual Pages (#631) * docs: break out hooks * Update links to appropriate hooks url * Logging queries guide * Fix docs site URLs * Fix hooks links * docs: GQty introduction * Revert "docs: GQty introduction" This reverts commit a952a04. * docs: intro to GQty Co-authored-by: William Johnston <[email protected]>
- Loading branch information
1 parent
c2c6bba
commit e3f68d1
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
slug: /gqty-intro | ||
title: Introduction to GQty | ||
description: Introduction to GQty in Faust.js | ||
--- | ||
|
||
Faust.js uses GQty under the hood for its GraphQL client. | ||
|
||
GQty is a new approach to a GraphQL client. Instead of defining queries by hand, GQty generates queries for you at runtime based on the data your app consumes. Take the following example: | ||
|
||
Your app consumes the `title` and `description` from `generalSettings`: | ||
|
||
```tsx title="Your App" | ||
import { client } from 'client' | ||
|
||
export default function App() { | ||
const query = client.useQuery() | ||
|
||
return( | ||
<h1>{query.generalSettings.title}</h1> | ||
<p>{query.generalSettings.description}</p> | ||
) | ||
} | ||
``` | ||
|
||
The following query is automatically generated and requested for you: | ||
|
||
```graphql | ||
query { | ||
generalSettings { | ||
title | ||
description | ||
} | ||
} | ||
``` | ||
|
||
## React Hooks | ||
|
||
GQty has React Hooks for fetching data, mutations, subscriptions, and more: | ||
|
||
- [useQuery](https://gqty.dev/docs/react/fetching-data#usequery) | ||
- [usePaginatedQuery](https://gqty.dev/docs/react/fetching-data#usepaginatedquery) | ||
- [useTransactionQuery](https://gqty.dev/docs/react/fetching-data#usetransactionquery) | ||
- [useLazyQuery](https://gqty.dev/docs/react/fetching-data#uselazyquery) | ||
- [useRefetch](https://gqty.dev/docs/react/fetching-data#userefetch) | ||
- [useMutation](https://gqty.dev/docs/react/mutations#usemutation) | ||
- [useSubscription](https://gqty.dev/docs/react/subscriptions#usesubscription) | ||
|
||
Faust.js exports these hooks from the `client`. You can use them in your React components like so: | ||
|
||
```tsx | ||
import { client } from 'client'; | ||
|
||
export default function App() { | ||
const { | ||
useQuery, | ||
usePaginatedQuery, | ||
useTransactionQuery, | ||
useLazyQuery, | ||
useRefetch, | ||
useMutation, | ||
useSubscription, | ||
} = client; | ||
|
||
return( | ||
... | ||
) | ||
} | ||
``` | ||
|
||
## Further Reading | ||
|
||
We recommend reading the ["What Is & Why"](https://gqty.dev/docs/intro) and ["How It Works"](https://gqty.dev/docs/intro/how-it-works) docs to get a better picture of how GQty works. | ||
|
||
Additionally, the following docs may be helpful: | ||
|
||
- [Features](https://gqty.dev/docs/intro/features) | ||
- [Fetching Data in React](https://gqty.dev/docs/react/fetching-data) | ||
- [react Suspense & Usage Without](https://gqty.dev/docs/react/suspense) | ||
- [Helper Functions](https://gqty.dev/docs/client/helper-functions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e3f68d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch main was deployed successfully
Your environment Production of app faustjs-site was successfully updated
View build logs: https://my.wpengine.com/atlas#/faustjs-site/cwa4v7z4d1u9vi7qw7hythg2/yps83ec2dj9bamzf2f5bchc9
View your environment URL: https://faustjs.org