-
Couldn't load subscription status.
- Fork 133
feat: execute/subscribe AsyncIterable API #211
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { DocumentNode, ExecutionResult, GraphQLSchema, print } from 'graphql'; | ||
| import { DocumentNode, ExecutionArgs, ExecutionResult, GraphQLSchema, print } from 'graphql'; | ||
| import { getGraphQLParameters, processRequest, Push } from 'graphql-helix'; | ||
| import { envelop, useSchema } from '@envelop/core'; | ||
| import { Envelop, Plugin } from '@envelop/types'; | ||
| import { envelop, makeExecute, useSchema } from '@envelop/core'; | ||
| import { Envelop, ExecuteFunction, Plugin } from '@envelop/types'; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
| export function createSpiedPlugin() { | ||
|
|
@@ -57,6 +57,7 @@ export function createTestkit( | |
| subscribe: (operation: DocumentNode | string, variables?: Record<string, any>, initialContext?: any) => Promise<Push<any, any>>; | ||
| replaceSchema: (schema: GraphQLSchema) => void; | ||
| wait: (ms: number) => Promise<void>; | ||
| executeRaw: ExecuteFunction; | ||
| } { | ||
| let replaceSchema: (s: GraphQLSchema) => void = () => {}; | ||
|
|
||
|
|
@@ -99,7 +100,6 @@ export function createTestkit( | |
| contextFactory: initialContext ? () => proxy.contextFactory(initialContext) : proxy.contextFactory, | ||
| schema: proxy.schema, | ||
| }); | ||
|
|
||
| return (r as any).payload as ExecutionResult; | ||
| }, | ||
| subscribe: async (operation, rawVariables = {}, initialContext = null) => { | ||
|
|
@@ -134,6 +134,13 @@ export function createTestkit( | |
|
|
||
| return r; | ||
| }, | ||
| executeRaw: makeExecute(async (args: ExecutionArgs) => { | ||
| const proxy = initRequest(); | ||
| return await proxy.execute({ | ||
| ...args, | ||
| contextValue: await proxy.contextFactory(args.contextValue), | ||
| }); | ||
| }), | ||
|
Comment on lines
+137
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dotansimha At the moment the testkit is pretty helix tailored. I assume this is in order to be more integration test-like, and closer to how envelop is used with actual network layers? I added this method here for now, but maybe we should in that case just construct all the stuff in place within the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove helix for testing, I initially used it because I wanted to test envelop with a request, but it's no longer needed. |
||
| }; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.