mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 21:40:21 +00:00
Add tests
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -15,7 +15,8 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user