Created
June 23, 2018 11:07
-
-
Save zapkub/2eba8ab7d7b9468a5654426a16ba1ef6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function graphql< | |
TProps extends TGraphQLVariables | {} = {}, | |
TData = {}, | |
TGraphQLVariables = {}, | |
TChildProps = Partial<DataProps<TData, TGraphQLVariables>> & | |
Partial<MutateProps<TData, TGraphQLVariables>> | |
>( | |
document: DocumentNode, | |
operationOptions: OperationOption<TProps, TData, TGraphQLVariables, TChildProps> = {}, | |
) { | |
switch (parser(document).type) { | |
case DocumentType.Mutation: | |
return mutation(document, operationOptions); | |
case DocumentType.Subscription: | |
return subscribe(document, operationOptions); | |
// case DocumentType.Fragment: | |
// throw new Error('fragments cannont currently be used on their own'); | |
case DocumentType.Query: | |
default: | |
return query(document, operationOptions); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment