riplog-view/frontend/index.tsx

49 lines
993 B
TypeScript

import React from "react";
import { render } from "react-dom";
import { ApolloProvider } from "@apollo/react-hooks";
import ApolloClient, { gql } from "apollo-boost";
import { InMemoryCache } from "apollo-cache-inmemory";
import App from "./src/App";
const cache = new InMemoryCache();
const client = new ApolloClient({
cache,
resolvers: {
Mutation: {
gotoChat: (_root, currentChat, { cache }) => {
const query = gql`
query GotoChatQuery {
currentChat {
workspace
channel
}
}
`;
currentChat.__typename = "ChatInfo";
cache.writeQuery({
query,
data: {
currentChat
}
});
return null;
}
}
},
uri: "http://localhost:8080/graphql"
});
cache.writeData({
data: {
currentChat: null
}
});
render(
<ApolloProvider client={client}>
<App />
</ApolloProvider>,
document.querySelector("main")
);