Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as React from "react"
import { createHttpClient } from "mst-gql"
import { render } from "react-dom"
import { TodoListView } from "./TodoListView"
import { RootStore } from "./models"
const ENDPOINT = `https://api.graphcms.com/simple/v1/cjfmozsww0sn70146fdqyuhst`
const store = RootStore.create(undefined, {
gqlHttpClient: createHttpClient(ENDPOINT)
})
render(, document.getElementById("root"))
export function initializeStore(
isServer: boolean,
snapshot = null
): ModelCreationType {
if (isServer) {
store = RootStore.create(undefined, {
gqlHttpClient: createHttpClient("http://localhost:3000/api/graphql"),
ssr: true
})
}
if (store === null) {
store = RootStore.create(undefined, {
gqlHttpClient: createHttpClient("http://localhost:3000/api/graphql")
})
}
if (snapshot) {
applySnapshot(store, snapshot)
}
return store
}
export function getStore(snapshot = null): ModelCreationType {
if (isServer || !store) {
store = RootStore.create(undefined, {
gqlHttpClient: createHttpClient("http://localhost:3000/api/graphql"),
ssr: true
})
}
if (snapshot) {
applySnapshot(store, snapshot)
}
return store
}
import React from "react"
import ReactDOM from "react-dom"
import { Observer } from "mobx-react-lite"
import Pages from "./pages"
import Login from "./pages/login"
import injectStyles from "./styles"
import { createHttpClient } from "mst-gql"
import { RootStore } from "./models"
import { StoreContext } from "./models/reactUtils"
const gqlHttpClient = createHttpClient("http://localhost:4000/graphql", {
headers: {
authorization: localStorage.getItem("token"),
"client-name": "Space Explorer [web]",
"client-version": "1.0.0"
}
})
const rootStore = RootStore.create(
{
loginStatus: localStorage.getItem("token") ? "loggedIn" : "loggedOut",
cartItems: []
},
{
gqlHttpClient
}
)
import React from "react"
import * as ReactDOM from "react-dom"
import { createHttpClient } from "mst-gql"
import "./index.css"
import { RootStore } from "./models/RootStore"
import { StoreContext } from "./models/reactUtils"
import { Home } from "./Home"
const rootStore = RootStore.create(undefined, {
gqlHttpClient: createHttpClient("http://localhost:3001/graphql")
})
export const App: React.FC = () => (
<main>
<h1>Todos</h1>
</main>
)
ReactDOM.render(, document.getElementById("root"))
import React from "react"
import * as ReactDOM from "react-dom"
import { createHttpClient } from "mst-gql"
import { SubscriptionClient } from "subscriptions-transport-ws"
import "./index.css"
import { RootStore } from "./models/RootStore"
import { StoreContext } from "./models/reactUtils"
import { Home } from "./components/Home"
import { Profile } from "./components/Profile"
const gqlHttpClient = createHttpClient("http://localhost:4000/graphql")
const gqlWsClient = new SubscriptionClient("ws://localhost:4000/graphql", {
reconnect: true
})
const rootStore = RootStore.create(undefined, {
gqlHttpClient,
gqlWsClient
})
export const App = () => (
<main>
</main>