From 2a005627d98078bb101eec54fb55fd5ff0e4371f Mon Sep 17 00:00:00 2001 From: Mike Marcacci Date: Wed, 27 Mar 2019 12:54:08 -0700 Subject: [PATCH] Add tests --- types/graphql-react/graphql-react-tests.tsx | 47 +++++++++++++++++++++ types/graphql-react/tsconfig.json | 3 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 types/graphql-react/graphql-react-tests.tsx diff --git a/types/graphql-react/graphql-react-tests.tsx b/types/graphql-react/graphql-react-tests.tsx new file mode 100644 index 0000000000..2ebd250332 --- /dev/null +++ b/types/graphql-react/graphql-react-tests.tsx @@ -0,0 +1,47 @@ +import React from "react"; +import { GraphQL, GraphQLContext, useGraphQL } from "graphql-react"; + +const graphql = new GraphQL(); + +function App() { + const { loading, cacheValue } = useGraphQL< + {node: null | {id: string}}, + {id: string} + >({ + fetchOptionsOverride(options) { + options.url = "/graphql"; + }, + variables: { + id: "123456" + }, + operation: { + query: ` + query($id: !String) { + node(id: $id) { + id + } + } + ` + } + }); + + if (loading) { + return
Loading...
; + } + + return ( +
{ + cacheValue && cacheValue.data && cacheValue.data.node + ? "exists" + : "does not exist" + }
+ ); +} + +function Root() { + return ( + + + + ); +} diff --git a/types/graphql-react/tsconfig.json b/types/graphql-react/tsconfig.json index 50cc7d19bc..d4b3672f9c 100644 --- a/types/graphql-react/tsconfig.json +++ b/types/graphql-react/tsconfig.json @@ -15,7 +15,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "jsx": "react" }, "files": [ "index.d.ts",