-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from graphcool/subscriptions
feat: added subscriptions support
- Loading branch information
Showing
7 changed files
with
142 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
import { GraphQLSchema } from 'graphql' | ||
import { FragmentReplacements } from './types' | ||
import { Handler } from './handler' | ||
import { Handler, SubscriptionHandler } from './handler' | ||
|
||
export function makeProxy<T extends object = any>({ | ||
schema, | ||
fragmentReplacements, | ||
operation | ||
operation, | ||
before, | ||
}: { | ||
schema: GraphQLSchema | ||
fragmentReplacements: FragmentReplacements | ||
operation: 'query' | 'mutation' | ||
before: () => void | ||
}): T { | ||
return new Proxy( | ||
{} as T, | ||
new Handler<T>(schema, fragmentReplacements, operation) | ||
new Handler<T>(schema, fragmentReplacements, operation, before), | ||
) | ||
} | ||
|
||
export function makeSubscriptionProxy<T extends object = any>({ | ||
schema, | ||
fragmentReplacements, | ||
before, | ||
}: { | ||
schema: GraphQLSchema | ||
fragmentReplacements: FragmentReplacements | ||
before: () => void | ||
}): T { | ||
return new Proxy( | ||
{} as T, | ||
new SubscriptionHandler<T>(schema, fragmentReplacements, before), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters