Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 2f78517

Browse files
committed
docs(cookbook/graphql): Add resources section to article
1 parent 87df42e commit 2f78517

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

public/docs/ts/latest/cookbook/graphql.jade

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ include ../_util-fns
2626
- [Performing a query](#querying)
2727

2828
- [Performing a mutation](#mutation)
29-
30-
- [Querying a realtime subscription](#more-observables)
3129

32-
- [Further resources](#parent-to-child-setter)
30+
- [Further resources](#resources)
3331

34-
- [Appendix: Setting up a GraphQL server](#parent-to-child-setter)
32+
- [Appendix: Setting up a GraphQL server](#server)
3533

3634
:marked
3735
**See the <live-example name="heroes-graphql"></live-example>**.
@@ -198,7 +196,7 @@ code-example(language="sh" class="code-shell").
198196
+makeExample('heroes-graphql/ts/app/client.2.ts', 'network-initialization')
199197
.l-sub-section
200198
:marked
201-
If you don't have a GraphQL server running, jump to the section about creating a GraphQL server.
199+
If you don't have a GraphQL server running, [jump to the section about creating a GraphQL server](#server).
202200
In that example we will show you how to run your GraphQL server in-memory on the client, as it is good for testing and also
203201
a helpful way to gradually move your app to GraphQL.
204202

@@ -245,25 +243,21 @@ code-example(language="sh" class="code-shell").
245243
:marked
246244
You can look at it as the equivalent of POST request in REST
247245
:marked
248-
code-example(language="sh" class="code-shell").
246+
code-example(language="json").
249247
mutation {
250-
addHero(heroName: "Russel Brand") {
248+
addHero(heroName: "Russell Brand") {
251249
id
252250
name
253251
}
254252
}
255-
age="html" format="linenums").
256-
format="linenums" language="typescript").
257-
format="linenums" language="js").
258-
code-example(language="json").
259253
:marked
260254
GraphQL mutations consist of two parts:
261255
1. The mutation name with arguments (`addHero`), which represents the actual operation to be done on the server (just like calling a function)
262256
2. The fields you want back from the result of the mutation to update the client (`id` and `name`) - which is very powerful - You, as the client developer can
263257
decide which fields you will get back, not something that the server will dictate for you
264258

265259
The result of the above mutation might be be:
266-
code-example(language="json" class="code-shell").
260+
code-example(language="json").
267261
{
268262
"data": {
269263
"addHero": {
@@ -289,5 +283,46 @@ code-example(language="json" class="code-shell").
289283

290284
Also, just like a query, the mutate function returns an Observable we can subscribe to and handle the data we asked for.
291285

286+
.l-main-section
287+
<a id="resources"></a>
288+
:marked
289+
## Further resources
290+
291+
* [GraphQL.org](http://graphql.org/) is a great website, with the following sections:
292+
* [Learn](http://graphql.org/learn/)
293+
* [Implementations in any language](http://graphql.org/code/)
294+
* [Community](http://graphql.org/community/)
295+
* [Apollo Developer resources](http://dev.apollodata.com/) - The [team](http://www.apollodata.com/) behind the Angular GraphQL client
296+
* [Apollo Dev Blog](https://dev-blog.apollodata.com/) - The most popular GraphQL blog
297+
298+
.l-main-section
299+
<a id="server"></a>
300+
:marked
301+
## Appendix: Setting up a GraphQL server
302+
303+
We are going to show you how to add a GraphQL server in Javascript.
304+
305+
Like the other examples on angular.io, we are going to run the server in the browser as part of our Angular app,
306+
it's good for testing and also if you want to start using GraphQL on your frontend without having a GraphQL backend.
307+
308+
.l-sub-section
309+
:marked
310+
You can learn how to run a full GraphQL backend on the [Apollo Server docs](http://dev.apollodata.com/tools/).
311+
The good thing is, that because it's Isomorphic Javascript, it is almost identical to the simple server we will run inside our Angular app
312+
:marked
313+
To start, let's create a file called `in-memory-graphql.ts` inside our Angular app.
314+
315+
First thing we should do is to create our GraphQL schema.
316+
.l-sub-section
317+
:marked
318+
The schema is pretty self explanatory, but if you want to dig deeper, check out [GraphQL.org learn section](http://graphql.org/learn/)
319+
+makeExample('heroes-graphql/ts/app/in-memory-graphql.ts', 'graphql-schema', 'Heroes GraphQL Schema')
320+
:marked
321+
322+
323+
324+
325+
326+
292327
:marked
293328
[Back to top](#top)

0 commit comments

Comments
 (0)