-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better support for interfaces as query responses (#305)
- Loading branch information
1 parent
6baf2b1
commit 3de4b6d
Showing
3 changed files
with
54 additions
and
3 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ See the [Fauna Documentation](https://docs.fauna.com/fauna/current/) for additio | |
- [Usage](#usage) | ||
- [Write FQL queries](#write-fql-queries) | ||
- [Typescript support](#typescript-support) | ||
- [Interfaces as `QueryValue` responses](#interfaces-as-queryvalue-responses) | ||
- [Query options](#query-options) | ||
- [Query statistics](#query-statistics) | ||
- [Pagination](#pagination) | ||
|
@@ -239,6 +240,25 @@ console.assert(userDoc.email === "[email protected]"); | |
client.close(); | ||
``` | ||
|
||
#### Interfaces as `QueryValue` responses | ||
|
||
To use a custom interface as a query response, extend the `QueryValueObject` | ||
interface. | ||
|
||
```typescript | ||
interface User extends QueryValueObject { | ||
name: string; | ||
email: string; | ||
} | ||
|
||
const query = fql`{ | ||
name: "Alice", | ||
email: "[email protected]", | ||
}`; | ||
|
||
const response: QuerySuccess<User> = await client.query<User>(query); | ||
``` | ||
|
||
### Query options | ||
|
||
Options are available to configure queries on each request. These override any | ||
|
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
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