Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): More callbacks, clearer differences and higher extensibility #40

Merged
merged 29 commits into from
Oct 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1aff2a6
fix: message type has to be a string always
enisdenjo Oct 23, 2020
10bf3ef
feat: add areGraphQLErrors and drop unused
enisdenjo Oct 23, 2020
3a9c54a
docs: why ignore
enisdenjo Oct 23, 2020
bad4172
feat: cleanup and begin with more callbacks and extensibility
enisdenjo Oct 23, 2020
6019b00
docs(protocol): refine and more explanations
enisdenjo Oct 23, 2020
7bcd100
feat: add `onOperation` and introduce operation result type
enisdenjo Oct 23, 2020
f721238
feat: all callbacks can return promises
enisdenjo Oct 23, 2020
9d1c3c0
feat: why not pass args along too
enisdenjo Oct 23, 2020
69b2aca
docs: generate
enisdenjo Oct 23, 2020
61c9d24
fix: onSubscribe test
enisdenjo Oct 23, 2020
eccc991
style: drop unused import
enisdenjo Oct 23, 2020
73c10c7
refactor: unnecessary export
enisdenjo Oct 23, 2020
75b9bf3
test: onNext behaviour
enisdenjo Oct 23, 2020
4e81b7c
test: onError behaviour
enisdenjo Oct 23, 2020
a54c11f
test: onComplete behaviour
enisdenjo Oct 23, 2020
f40eb85
test: onSubscribe returned error behaviour
enisdenjo Oct 23, 2020
143912a
test: throwing errors from callbacks
enisdenjo Oct 23, 2020
21a72b9
fix: dont forget to await
enisdenjo Oct 23, 2020
862a6dc
style: drop unused import
enisdenjo Oct 23, 2020
4fc183d
docs: custom graphql arguments recipe
enisdenjo Oct 23, 2020
62a4594
docs: persisted queries recipe (and test to make sure)
enisdenjo Oct 23, 2020
7b9199e
fix: correct tag close
enisdenjo Oct 23, 2020
385caf8
docs: remind to validate with onSubscribe
enisdenjo Oct 23, 2020
8a3c7d4
docs: static and dynamic graphql arguments
enisdenjo Oct 23, 2020
732be2b
fix: from msg payload
enisdenjo Oct 23, 2020
eef812f
style: simplifty
enisdenjo Oct 23, 2020
f683819
feat: onConnect can return nothing
enisdenjo Oct 23, 2020
2cc2032
docs: refine logging recipe
enisdenjo Oct 23, 2020
7a0414f
docs: generate [skip ci]
enisdenjo Oct 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: custom graphql arguments recipe
  • Loading branch information
enisdenjo committed Oct 23, 2020
commit 4fc183d8cf20d0c75d40d3ae9656d0fdfcf69cdf
33 changes: 25 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ server.listen(443);
</details>

<details>
<summary>Server usage with a custom GraphQL context</summary>
<summary>Server usage with custom GraphQL arguments</summary>

```typescript
import { execute, subscribe } from 'graphql';
Expand All @@ -507,16 +507,33 @@ import { schema } from 'my-graphql-schema';

createServer(
{
context: getStaticContext(),
schema,
execute,
subscribe,
onSubscribe: (ctx, msg, args) => {
return [
{
...args,
contextValue: getCustomContext(ctx, msg, args),
},
];
},
{
server,
path: '/graphql',
},
);

// or create execution args dynamically on every subscription

import { parse } from 'graphql';

createServer(
{
execute,
subscribe,
onSubscribe: (ctx, msg) => {
return {
schema,
contextValue: getDynamicContext(ctx, msg),
operationName: msg.operationName,
document: parse(msg.operationName),
variableValues: msg.variables,
};
},
},
{
Expand Down