Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-admin): show error messages in the interface #25944

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/gatsby-admin/src/components/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react"
import { Provider, Client } from "urql"
import { ThemeProvider, getTheme } from "gatsby-interface"
import { ThemeProvider as StrictUIProvider } from "strict-ui"
import { Spinner } from "theme-ui"
import { createUrqlClient } from "../urql-client"

const baseTheme = getTheme()
Expand Down Expand Up @@ -49,10 +50,15 @@ const GraphQLProvider: React.FC<{}> = ({ children }) => {
})
}, [])

if (status === `loading`) return <p>Loading...</p>
if (status === `loading`) return <Spinner />

if (client === null)
return <p>It looks like no develop process is running.</p>
return (
<p>
Please start <code>gatsby develop</code> to show the data about your
site.
</p>
)

return <Provider value={client}>{children}</Provider>
}
Expand Down
9 changes: 8 additions & 1 deletion packages/gatsby-admin/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ const Index: React.FC<{}> = () => {

if (fetching) return <Spinner />

if (error) return <p>Oops something went wrong.</p>
if (error) {
const errMsg =
(error.networkError && error.networkError.message) ||
(Array.isArray(error.graphQLErrors) &&
error.graphQLErrors.map(e => e.message).join(` | `))

return <p>Error: {errMsg}</p>
}

return (
<Flex gap={7} flexDirection="column" sx={{ paddingY: 7, paddingX: 6 }}>
Expand Down