1
- # json-to-graphql
1
+ # json-to-graphql-query
2
2
3
3
This is a simple module that takes a JavaScript object and turns it into a
4
4
GraphQL query to be sent to a GraphQL server.
@@ -8,15 +8,20 @@ Mainly useful for applications that need to generate graphql queries dynamically
8
8
## Installation
9
9
10
10
```
11
- npm install json-to-graphql
11
+ npm install json-to-graphql-query
12
12
```
13
13
14
14
## Usage
15
15
16
+ ** jsonToGraphQLQuery(** queryObject: object, options?: object ** )**
17
+
18
+ Supported options:
19
+ * ** pretty** : boolean - Set to ` true ` to enable pretty-printed output
20
+
16
21
### Simple Query
17
22
18
23
``` typescript
19
- import { jsonToGraphQL } from ' json-to-graphql' ;
24
+ import jsonToGraphQLQuery from ' json-to-graphql-query ' ;
20
25
21
26
const query = {
22
27
query: {
@@ -27,7 +32,7 @@ const query = {
27
32
}
28
33
}
29
34
};
30
- const graphql_query = jsonToGraphQL (query , { pretty: true });
35
+ const graphql_query = jsonToGraphQLQuery (query , { pretty: true });
31
36
```
32
37
33
38
Resulting ` graphql_query `
@@ -45,7 +50,7 @@ query {
45
50
### Query with arguments
46
51
47
52
``` typescript
48
- import { jsonToGraphQL } from ' json-to-graphql' ;
53
+ import jsonToGraphQLQuery from ' json-to-graphql-query ' ;
49
54
50
55
const query = {
51
56
query: {
@@ -60,7 +65,7 @@ const query = {
60
65
}
61
66
}
62
67
};
63
- const graphql_query = jsonToGraphQL (query , { pretty: true });
68
+ const graphql_query = jsonToGraphQLQuery (query , { pretty: true });
64
69
```
65
70
66
71
Resulting ` graphql_query `
@@ -78,7 +83,7 @@ query {
78
83
### Query with nested objects
79
84
80
85
``` typescript
81
- import { jsonToGraphQL } from ' json-to-graphql' ;
86
+ import jsonToGraphQLQuery from ' json-to-graphql-query ' ;
82
87
83
88
const query = {
84
89
query: {
@@ -93,7 +98,7 @@ const query = {
93
98
}
94
99
}
95
100
};
96
- const graphql_query = jsonToGraphQL (query , { pretty: true });
101
+ const graphql_query = jsonToGraphQLQuery (query , { pretty: true });
97
102
```
98
103
99
104
Resulting ` graphql_query `
0 commit comments