Skip to content

Commit 607a4d8

Browse files
committed
updated readme
1 parent 2fe8fb2 commit 607a4d8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,33 @@ yarn add -D simple-graphql-to-typescript
5050

5151
## Quick Exemples
5252

53-
### With autogenerated, fully-typed and abortable Apollo handlers
53+
### With generated, fully-typed and abortable Apollo handlers, and generated fragments
5454

5555
```bash
56-
sgts -e https://graphql.anilist.co/ -o ./generated.ts --codegen-functions
56+
sgts -e https://graphql.anilist.co/ -o ./generated.ts --codegen-functions --gen-fragments
5757
```
5858

5959
```typescript
6060
import { apiProvider } from './generated.ts';
61+
import { ApolloClient } from '@apollo/client/core';
6162

6263
const sgts = apiProvider(
6364
new ApolloClient({ uri: 'https://graphql.anilist.co/', cache: new InMemoryCache() })
6465
);
66+
// Declare the main api source with your ApolloClient constructor
6567

6668
const mediaListQuery = sgts.MediaList().$args({ sort: [MediaListSort.Added_time] });
6769

68-
setTimeOut(() => mediaListQuery.$abort(), 50);
70+
// You can still add fallback fragment by passing it to the first method
71+
// `sgts.MediaList(`id status`)...`
72+
// Or
73+
// `sgts.MediaList(gql`fragment MediaListFragment on MediaList { ... }`)...`
6974

7075
const mediaList = await mediaListQuery.$fetch();
7176
console.log(mediaList);
77+
78+
mediaListQuery.$abort();
79+
// You can abort the query anytime
7280
```
7381

7482
### With only GraphQL types transpiled to Typescript interfaces

0 commit comments

Comments
 (0)