You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now you can query your data in graphql. For instance, to issue the following query:
68
44
69
45
```graphql
70
-
query{
71
-
Customer(id: 1) {
46
+
{
47
+
Post(id: 1) {
72
48
id
73
-
first_name
74
-
last_name
49
+
title
50
+
views
51
+
User {
52
+
name
53
+
}
54
+
Comments {
55
+
body
56
+
}
75
57
}
76
58
}
77
59
```
78
60
79
-
Go to http://localhost:3000/?query=query%20%7B%20Post(id%3A%201)%20%7Bid%20title%20views%20%7D%7D. You'll get the following result:
61
+
Go to http://localhost:3000/?query=%7B%20Post%28id%3A%201%29%20%7B%20id%20title%20views%20User%20%7B%20name%20%7D%20Comments%20%7B%20body%20%7D%20%7D%20%7D. You'll get the following result:
80
62
81
63
```json
82
64
{
@@ -85,12 +67,19 @@ Go to http://localhost:3000/?query=query%20%7B%20Post(id%3A%201)%20%7Bid%20title
85
67
"id": "1",
86
68
"title": "Lorem Ipsum",
87
69
"views": 254,
70
+
"User": {
71
+
"name": "John Doe"
72
+
},
73
+
"Comments": [
74
+
{ "body": "Consectetur adipiscing elit" },
75
+
{ "body": "Nam molestie pellentesque dui" },
76
+
]
88
77
}
89
78
}
90
79
}
91
80
```
92
81
93
-
The json-graphql-server accepts queries in GET and POST. Under the hood, it uses [Apollo's `graphql-server` module](http://dev.apollodata.com/tools/graphql-server/requests.html). Please refer to their documentations for details about passing variables, etc.
82
+
The json-graphql-server accepts queries in GET and POST. Under the hood, it uses [the `express-graphql` module](https://github.com/graphql/express-graphql). Please refer to their documentations for details about passing variables, etc.
94
83
95
84
Note that the server is [GraphiQL](https://github.com/skevy/graphiql-app/releases) enabled, so you can query your server using a full-featured graphical user interface, providing autosuggest, history, etc.
96
85
@@ -112,7 +101,8 @@ type Post {
112
101
title: String!
113
102
views: Int
114
103
user_id: ID
115
-
tag_id: ID
104
+
User: User
105
+
Comments: [Comment]
116
106
}
117
107
typeQuery {
118
108
Post(id: ID!): Post
@@ -173,7 +163,6 @@ Here is how you can use the queries and mutations generated for your data, using
173
163
title
174
164
views
175
165
user_id
176
-
tag_id
177
166
}
178
167
}
179
168
</pre>
@@ -186,8 +175,7 @@ Here is how you can use the queries and mutations generated for your data, using
186
175
"id": 1,
187
176
"title": "Lorem Ipsum",
188
177
"views": 254,
189
-
"user_id": 123,
190
-
"tag_id": "foo"
178
+
"user_id": 123
191
179
}
192
180
}
193
181
}
@@ -246,7 +234,7 @@ Deploy with Heroku or Next.js.
246
234
247
235
## Roadmap
248
236
249
-
*Handle relationships
237
+
*Filtering in the `all*` queries
250
238
* Client-side mocking (à la [FakeRest](https://github.com/marmelab/FakeRest))
Admin-on-rest is licensed under the [MIT Licence](https://github.com/marmelab/json-graphql-server/blob/master/LICENSE.md), sponsored and supported by [marmelab](http://marmelab.com).
0 commit comments