File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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
6060import { apiProvider } from ' ./generated.ts' ;
61+ import { ApolloClient } from ' @apollo/client/core' ;
6162
6263const 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
6668const 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
7075const mediaList = await mediaListQuery .$fetch ();
7176console .log (mediaList );
77+
78+ mediaListQuery .$abort ();
79+ // You can abort the query anytime
7280```
7381
7482### With only GraphQL types transpiled to Typescript interfaces
You can’t perform that action at this time.
0 commit comments