Skip to content

Commit

Permalink
fix(gatsby-admin): show error messages in the interface (#25944)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxstbr authored Jul 23, 2020
1 parent 718279a commit 491197f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
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

0 comments on commit 491197f

Please sign in to comment.