How to get a story
There are multiple possibilities of getting a story, here are two:
The first one is the same as in the Quickstart. Use the resolver called story where you can pass a slug (being the visible integer in the url of a story).
Example: Get the title and the name of its author of the latest version of the story with the slug 123
graphqlquery {story(slug: 123) {idslugversion {title}user {name}}}
This should return a JSON like this:
response{"data": {"story": {"id": "TWU6MTIz","slug": 123,"version": {"title": "Hello world!"},"user": {"name": "John Doe"}}}}
The second one is a query via the entry point called node by using the GraphQL id, for more information about it see the Introduction to GraphQL section.
For example:
graphqlquery {node(id: "az3QSdkm") {... on Story {idversion {title}user {name}}}}
Note the difference with the previous one, wrapping the fields in ... on Story
that is allowing us to cast the expected return to be a Story.
The only difference with the previous example in the returned data will be the name of the variable:
Instead of:
response{"data": {"story": {"id": "TWU6MTIz"}}}
You will receive a structure like this:
response{"data": {"node": {"id": "TWU6MTIz"}}}
If you want to have the same response, you can add an alias to node. For example, in this case in the query you could do:
graphqlquery {story: node(id: "az3QSdkm") {... on Story {id}}}