Guest User

Untitled

a guest
Jun 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. export function graphql<
  2. TProps extends TGraphQLVariables | {} = {},
  3. TData = {},
  4. TGraphQLVariables = {},
  5. TChildProps = Partial<DataProps<TData, TGraphQLVariables>> &
  6. Partial<MutateProps<TData, TGraphQLVariables>>
  7. >(
  8. document: DocumentNode,
  9. operationOptions: OperationOption<TProps, TData, TGraphQLVariables, TChildProps> = {},
  10. ) {
  11. switch (parser(document).type) {
  12. case DocumentType.Mutation:
  13. return mutation(document, operationOptions);
  14. case DocumentType.Subscription:
  15. return subscribe(document, operationOptions);
  16. // case DocumentType.Fragment:
  17. // throw new Error('fragments cannont currently be used on their own');
  18. case DocumentType.Query:
  19. default:
  20. return query(document, operationOptions);
  21. }
  22. }
Add Comment
Please, Sign In to add comment