Skip to content

Commit b5bd14b

Browse files
committed
docs: browser and node client usage [skip ci]
1 parent f25241d commit b5bd14b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,53 @@ const client = createClient({
468468

469469
</details>
470470

471+
<details id="browser">
472+
<summary><a href="#browser">🔗</a> Client usage in browser</summary>
473+
474+
```html
475+
<!DOCTYPE html>
476+
<html>
477+
<head>
478+
<meta charset="utf-8" />
479+
<title>GraphQL over HTTP</title>
480+
<script
481+
type="text/javascript"
482+
src="https://unpkg.com/graphql-http/umd/graphql-http.min.js"
483+
></script>
484+
</head>
485+
<body>
486+
<script type="text/javascript">
487+
const client = graphqlHttp.createClient({
488+
url: 'http://umdfor.the:4000/win/graphql',
489+
});
490+
491+
// consider other recipes for usage inspiration
492+
</script>
493+
</body>
494+
</html>
495+
```
496+
497+
</details>
498+
499+
<details id="node-client">
500+
<summary><a href="#node-client">🔗</a> Client usage in Node</summary>
501+
502+
```js
503+
const fetch = require('node-fetch'); // yarn add node-fetch
504+
const { AbortController } = require('node-abort-controller'); // (node < v15) yarn add node-abort-controller
505+
const { createClient } = require('graphql-sse');
506+
507+
const client = createClient({
508+
url: 'http://no.browser:4000/graphql',
509+
fetchFn: fetch,
510+
abortControllerImpl: AbortController, // node < v15
511+
});
512+
513+
// consider other recipes for usage inspiration
514+
```
515+
516+
</details>
517+
471518
<details id="auth">
472519
<summary><a href="#auth">🔗</a> Server handler usage with authentication</summary>
473520

0 commit comments

Comments
 (0)