3.2.0 • Published 4 years ago
@hydre/graphql-batch-executor v3.2.0
This library is made to be used by servers or tools implementer, it can't be used alone.
Install
npm install @hydre/graphql-batch-executor
Usage
Initialize a new Executor per client
import Executor from '@hydre/graphql-batch-executor'
import make_schema from '@hydre/graphql-batch-executor/make_schema'
// i actually wrote a light and efficient version of makeExecutableSchema
// without the shitty code and the 7500 dependencies of graphql-tools
// and using mjs exports of graphql.js
const schema = make_schema({
document: 'type Query { ping: String! }',
resolvers: {
Query: {
ping: () => 'pong'
},
Subscription: {
ping: {
resolve: () => 'pong',
async *subscribe() {
yield 0
}
}
}
},
directives: {
foo: ({ resolve, // original resolver
root, // resolver params in the same order
parameters, // .
context, // .
info, // .
directive_arguments, // parameters for the directive
}) => {}
}
})
const executor = new Executor({
schema, // schema
context: async () => ({}),
formatError: x => x // format array of errors
})
The executor generator takes an option object
import stream from 'stream'
stream.pipeline(
executor.execute({
document: /* GraphQL */`
query foo {
ping
}
query bar {
ping
}
`,
variables: {},
}),
async source => {
for await (const chunk of source) {
const {
// query, mutation, subscription
operation_type,
// the name
// note that you can't send queries
// without names if there are more than one
operation_name,
// data result or null
data,
// gql errors or []
errors,
} = chunk
}
},
() => {
log('client disconnected')
},
)
Advanced
see /examples
3.2.0
4 years ago
3.1.3
5 years ago
3.1.2
5 years ago
3.1.1
5 years ago
3.1.0
5 years ago
3.0.4
5 years ago
3.0.3
5 years ago
3.0.2
5 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.0.9
5 years ago
2.0.8
5 years ago
2.0.7
5 years ago
2.0.6
5 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.2.4
5 years ago
1.2.3
5 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.1.6
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.0
5 years ago