diff --git a/src/app/HomePage.js b/src/app/HomePage.js index d7f75d39..15aca5de 100644 --- a/src/app/HomePage.js +++ b/src/app/HomePage.js @@ -288,15 +288,17 @@ function NewItemsSection() { } function NewItemsSectionContent() { - const { loading, error, data } = useQuery(gql` - query NewItemsSection { - newestItems { - id - name - thumbnailUrl + const { loading, error, data } = useQuery( + gql` + query NewItemsSection_NoAuthRequired { + newestItems { + id + name + thumbnailUrl + } } - } - `); + ` + ); if (loading) { return ( diff --git a/src/app/apolloClient.js b/src/app/apolloClient.js index 0f4cb5ba..9a98f224 100644 --- a/src/app/apolloClient.js +++ b/src/app/apolloClient.js @@ -142,7 +142,15 @@ const persistedQueryLink = createPersistedQueryLink({ }); const httpLink = createHttpLink({ uri: "/api/graphql" }); const buildAuthLink = (getAuth0) => - setContext(async (_, { headers }) => { + setContext(async ({ operationName }, { headers }) => { + // Our little hack to decorate queries that don't need auth, and can load + // without waiting for it! + // TODO: It feels like inverting this might be the better way to go?... + const skipAuth = operationName?.includes("_NoAuthRequired"); + if (skipAuth) { + return; + } + // Wait for auth0 to stop loading, so we can maybe get a token! We'll do // this hackily by checking every 100ms until it's true. await new Promise((resolve) => { diff --git a/src/app/components/SpeciesColorPicker.js b/src/app/components/SpeciesColorPicker.js index 768c4833..dfc2d201 100644 --- a/src/app/components/SpeciesColorPicker.js +++ b/src/app/components/SpeciesColorPicker.js @@ -29,7 +29,7 @@ function SpeciesColorPicker({ onChange, }) { const { loading: loadingMeta, error: errorMeta, data: meta } = useQuery(gql` - query SpeciesColorPicker { + query SpeciesColorPicker_NoAuthRequired { allSpecies { id name