diff --git a/app/graphql/schema/utils.ts b/app/graphql/schema/utils.ts index 106efcd47..c60170bc6 100644 --- a/app/graphql/schema/utils.ts +++ b/app/graphql/schema/utils.ts @@ -49,6 +49,7 @@ type makeNullUndefinedAndOptional = { type Server = makeNullUndefinedAndOptional; export const getServers = async (): Promise => { + // Check if we have the servers already cached, if so return them const cachedServers = userCache.get('mine')?.servers; if (cachedServers) { return cachedServers; @@ -75,6 +76,12 @@ export const getServers = async (): Promise => { servers }); + // Get first server's owner object + const owner = servers[0].owner; + + // Publish owner event + await pubsub.publish('owner', owner); + // Return servers from mothership return servers; } diff --git a/app/utils.ts b/app/utils.ts index 805577170..8dee509e5 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -21,12 +21,11 @@ export const getServers = async (apiKey: string) => fetch(MOTHERSHIP_GRAPHQL_LIN .then(async response => { const { data, errors } = await response.json(); if (errors) { - return new Error(errors[0].message); + throw new Error(errors[0].message); } return data.servers as Promise; }) - .catch(error => { + .catch((error: Error) => { Sentry.captureException(error); - return error; });