Skip to content

Commit 042986c

Browse files
Update README.md
1 parent ffc2bbc commit 042986c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ api.mount('SearchUsers').at('/users')
7373
api.listen(3000);
7474
```
7575

76-
See [Usage with Express](/#) and read [Getting Started](/#) to see all available options.
76+
See [Usage with Express](#usage-with-express) and read [Getting Started](#getting-started) to see all available options.
7777

7878
## External GraphQL API
7979
When dealing with a publicly exposed GraphQL server that implements users and priveleges, the main benefit GraphQL Rest Client provides is caching. While implementing individual caches at a content-level with push-expiration in the GraphQL server is optimal, building these systems is laborous and isn't always prioritized in an MVP product. GraphQL Rest Client allows you to expose a GraphQL query as a REST endpoing with built in cache management that is compatible with all CDNs and cache management layers (e.g. CloudFlare, Akamai, Varnish, etc).
@@ -126,9 +126,18 @@ query GetFirstUser {
126126
lastName
127127
}
128128
}
129+
130+
# THIS
131+
query GetUser($id: ID!) {
132+
getUser(id: $id) {
133+
id
134+
firstName
135+
lastName
136+
}
137+
}
129138
```
130139

131-
Once you have your schema and your endpoint, instantiation is straight-forward:
140+
Once you have your schema and your endpoint, usage is straight-forward:
132141

133142
```js
134143
import GraphQLRestRouter from 'graphql-rest-router';
@@ -137,6 +146,11 @@ const schema = fs.readFile(`${__dirname}/schema.gql`);
137146
const endpoint = 'http://mygraphqlserver.com:9000';
138147

139148
const api = new GraphQLRestRouter(endpoint, schema);
149+
150+
api.mount('GetFirstUser').at('/users/first');
151+
api.mount('GetUser').at('/users/:id');
152+
153+
api.listen(3000);
140154
```
141155

142156
### Creating Endpoints
@@ -152,7 +166,7 @@ api.mount('OperationName'); // Mounts "query OperationName" as "GET /OperationNa
152166
By default, mounted queries are GET requests. If you'd like to change that you may specify any http method using `.as()` on a route.
153167

154168
Example:
155-
```
169+
```js
156170
const api = new GraphQLRestRouter(endpoint, schema);
157171

158172
api.mount('GetUserById'); // GET /GetUserById

0 commit comments

Comments
 (0)