Add tests

This commit is contained in:
Mike Marcacci
2019-03-27 12:54:08 -07:00
parent 6c7213110a
commit 2a005627d9
2 changed files with 49 additions and 1 deletions
@@ -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 <div>Loading...</div>;
}
return (
<div>{
cacheValue && cacheValue.data && cacheValue.data.node
? "exists"
: "does not exist"
}</div>
);
}
function Root() {
return (
<GraphQLContext.Provider value={graphql}>
<App />
</GraphQLContext.Provider>
);
}
+2 -1
View File
@@ -15,7 +15,8 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",