diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-17 23:43:30 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-17 23:43:30 +0200 |
| commit | d2cd7f1b4c318ac8587ab3dc1dec4a44b6d592fe (patch) | |
| tree | 0b8c84560f661da92137d4f4fa59ed493ce2feab /src | |
| parent | 0472e8073b9df492596e550fc79c42ca93ba14c0 (diff) | |
Start migration to supabase
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/config/apollo.ts | 3 | ||||
| -rw-r--r-- | src/lib/config/config.ts | 1 | ||||
| -rw-r--r-- | src/lib/config/env.dist | 1 | ||||
| -rw-r--r-- | src/lib/data/queries.ts | 16 | ||||
| -rw-r--r-- | src/lib/stores/apollo.ts | 2 | ||||
| -rw-r--r-- | src/lib/stores/forums.ts | 2 |
6 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/config/apollo.ts b/src/lib/config/apollo.ts index 826fd28..a8b27ef 100644 --- a/src/lib/config/apollo.ts +++ b/src/lib/config/apollo.ts @@ -8,6 +8,9 @@ export const client = new ApolloClient({ cache, link: new HttpLink({ uri: apolloConfig.uri, + headers: { + apiKey: apolloConfig.key + }, fetch }), ...apolloConfig diff --git a/src/lib/config/config.ts b/src/lib/config/config.ts index efb7dea..2bf9bc1 100644 --- a/src/lib/config/config.ts +++ b/src/lib/config/config.ts @@ -10,6 +10,7 @@ const internals = { export const apollo = { uri: import.meta.env.VITE_APOLLO_SERVER, + key: import.meta.env.VITE_APOLLO_KEY, name: 'forum', version: internals.version }; diff --git a/src/lib/config/env.dist b/src/lib/config/env.dist index 1f3ff0c..2d95266 100644 --- a/src/lib/config/env.dist +++ b/src/lib/config/env.dist @@ -1 +1,2 @@ VITE_APOLLO_SERVER=http://location_of_apollo_server +VITE_APOLLO_KEY="" diff --git a/src/lib/data/queries.ts b/src/lib/data/queries.ts index 7364c0f..4def052 100644 --- a/src/lib/data/queries.ts +++ b/src/lib/data/queries.ts @@ -2,12 +2,16 @@ import { gql } from '@apollo/client/core'; export const GET_FORUMS = gql` query GetForums { - forums { - id - glyph - label - position - } + forumsCollection { + edges { + node { + id + glyph + label + position + } + } + } } `; diff --git a/src/lib/stores/apollo.ts b/src/lib/stores/apollo.ts index 4ef1986..c75dd87 100644 --- a/src/lib/stores/apollo.ts +++ b/src/lib/stores/apollo.ts @@ -52,7 +52,7 @@ export const store = function store<Type>({ set({ loading: false, - data: result.data[key], + data: result.data[key].edges.map((item) => item.node), error: undefined }); }, diff --git a/src/lib/stores/forums.ts b/src/lib/stores/forums.ts index 8a395b3..0ff09f7 100644 --- a/src/lib/stores/forums.ts +++ b/src/lib/stores/forums.ts @@ -6,4 +6,4 @@ import type { Forum } from '$lib/data/types'; export const getForum = (id: string) => store<Forum>({ key: 'forum', query: GET_FORUM, variables: { id } }); export const getForums = () => - store<Forum[]>({ key: 'forums', query: GET_FORUMS, initialValue: [] }); + store<Forum[]>({ key: 'forumsCollection', query: GET_FORUMS, initialValue: [] }); |