Skip to content

Commit c705bf7

Browse files
author
jeniffer9
authored
Update README.md
1 parent 0e87e3d commit c705bf7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Supported Options:
3131
* Support for Enum values via [`EnumType`](#query-with-enum-values)
3232
* Support for variables via [`__variables`](#query-with-variables)
3333
* Support for simple directives (such as `@client`) via [`__directives`](#query-with-directives)
34+
* Support for inline fragments via [`__on`].[`__fragmentName`](#query-with-inline-fragments)
3435

3536
## Recent Changes
3637

@@ -341,6 +342,38 @@ query {
341342
}
342343
```
343344

345+
### Query with Inline Fragments
346+
347+
```typescript
348+
import { jsonToGraphQLQuery } from 'json-to-graphql-query';
349+
350+
const query = {
351+
query: {
352+
Posts: {
353+
__on: {
354+
__fragmentName: "ConfigurablePost",
355+
id: true
356+
},
357+
title: true
358+
}
359+
}
360+
};
361+
const graphql_query = jsonToGraphQLQuery(query, { pretty: true });
362+
```
363+
364+
Resulting `graphql_query`
365+
366+
```graphql
367+
query {
368+
Posts {
369+
... on ConfigurablePost {
370+
id
371+
}
372+
title
373+
}
374+
}
375+
```
376+
344377
## TO-DO List
345378

346379
* Support Named Queries / Mutations

0 commit comments

Comments
 (0)