@@ -48,13 +48,77 @@ npm i simple-graphql-to-typescript --save-dev
4848yarn add -D simple-graphql-to-typescript
4949```
5050
51+ ## Quick Exemples
52+
53+ ### With autogenerated, fully-typed and abortable Apollo handlers
54+
55+ ``` bash
56+ sgts -e https://graphql.anilist.co/ -o ./generated.ts --codegen-functions
57+ ```
58+
59+ ``` typescript
60+ import { apiProvider } from ' ./generated.ts' ;
61+
62+ const sgts = apiProvider (
63+ new ApolloClient ({ uri: ' https://graphql.anilist.co/' , cache: new InMemoryCache () })
64+ );
65+
66+ const mediaListQuery = sgts .MediaList ().$args ({ sort: [MediaListSort .Added_time ] });
67+
68+ setTimeOut (() => mediaListQuery .$abort (), 50 );
69+
70+ const mediaList = await mediaListQuery .$fetch ();
71+ console .log (mediaList );
72+ ```
73+
74+ ### With only GraphQL types transpiled to Typescript interfaces
75+
76+ ``` bash
77+ sgts -e https://graphql.anilist.co/ -o ./generated.ts
78+ ```
79+
80+ Part of the generated output:
81+
82+ ``` typescript
83+ ...
84+
85+ /** A user's general options */
86+ export interface UserOptions {
87+ /** The language the user wants to see media titles in*/
88+ titleLanguage: Maybe <UserTitleLanguage >;
89+ /** Whether the user has enabled viewing of 18+ content*/
90+ displayAdultContent: Maybe <boolean >;
91+ /** Whether the user receives notifications when a show they are watching aires*/
92+ airingNotifications: Maybe <boolean >;
93+ /** Profile highlight color (blue, purple, pink, orange, red, green, gray)*/
94+ profileColor: Maybe <string >;
95+ /** Notification options*/
96+ notificationOptions: Maybe <NotificationOption []>;
97+ /** The user's timezone offset (Auth user only)*/
98+ timezone: Maybe <string >;
99+ /** Minutes between activity for them to be merged together. 0 is Never, Above 2 weeks (20160 mins) is Always.*/
100+ activityMergeTime: Maybe <number >;
101+ }
102+
103+ /** The language the user wants to see media titles in */
104+ export enum UserTitleLanguage {
105+ Romaji = ' ROMAJI' ,
106+ English = ' ENGLISH' ,
107+ Native = ' NATIVE' ,
108+ Romaji_stylised = ' ROMAJI_STYLISED' ,
109+ English_stylised = ' ENGLISH_STYLISED' ,
110+ Native_stylised = ' NATIVE_STYLISED' ,
111+ }
112+ ...
113+ ```
114+
51115## Help
52116
53117``` bash
54118sgts -h
55119```
56120
57- ## ** Documentation **
121+ ## ** Options **
58122
59123| Option | Short syntax | Type | Usage |
60124| --------------------------- | ------------ | -------------------------------------------- | -------------------------------------------------------------------- |
0 commit comments