From c3c3fc6720349380faa8aa0394ffa2dc85fd84d4 Mon Sep 17 00:00:00 2001 From: Akash K <57758277+amk-dev@users.noreply.github.com> Date: Tue, 4 Apr 2023 04:10:32 +0530 Subject: [PATCH] chore: use IDs instead of Strings in graphql queries (#2961) --- .../gql/queries/GetCollectionChildren.graphql | 2 +- .../queries/GetCollectionChildrenIDs.graphql | 2 +- packages/hoppscotch-web/src/firebase/init.ts | 26 +++++++++++++++++++ packages/hoppscotch-web/src/main.ts | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 packages/hoppscotch-web/src/firebase/init.ts diff --git a/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildren.graphql b/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildren.graphql index 0dac0aa74..b86f38e47 100644 --- a/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildren.graphql +++ b/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildren.graphql @@ -1,4 +1,4 @@ -query GetCollectionChildren($collectionID: ID!, $cursor: String) { +query GetCollectionChildren($collectionID: ID!, $cursor: ID) { collection(collectionID: $collectionID) { children(cursor: $cursor) { id diff --git a/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildrenIDs.graphql b/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildrenIDs.graphql index 67299f0f9..500677d63 100644 --- a/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildrenIDs.graphql +++ b/packages/hoppscotch-common/src/helpers/backend/gql/queries/GetCollectionChildrenIDs.graphql @@ -1,4 +1,4 @@ -query GetCollectionChildrenIDs($collectionID: ID!, $cursor: String) { +query GetCollectionChildrenIDs($collectionID: ID!, $cursor: ID) { collection(collectionID: $collectionID) { children(cursor: $cursor) { id diff --git a/packages/hoppscotch-web/src/firebase/init.ts b/packages/hoppscotch-web/src/firebase/init.ts new file mode 100644 index 000000000..854dd1d58 --- /dev/null +++ b/packages/hoppscotch-web/src/firebase/init.ts @@ -0,0 +1,26 @@ +import { initializeApp } from "firebase/app" + +const firebaseConfig = { + apiKey: import.meta.env.VITE_API_KEY, + authDomain: import.meta.env.VITE_AUTH_DOMAIN, + databaseURL: import.meta.env.VITE_DATABASE_URL, + projectId: import.meta.env.VITE_PROJECT_ID, + storageBucket: import.meta.env.VITE_STORAGE_BUCKET, + messagingSenderId: import.meta.env.VITE_MESSAGING_SENDER_ID, + appId: import.meta.env.VITE_APP_ID, + measurementId: import.meta.env.VITE_MEASUREMENT_ID, +} + +let initialized = false + +export function initializeFirebase() { + if (!initialized) { + try { + initializeApp(firebaseConfig) + initialized = true + } catch (e) { + // initializeApp throws exception if we reinitialize + initialized = true + } + } +} diff --git a/packages/hoppscotch-web/src/main.ts b/packages/hoppscotch-web/src/main.ts index 266b5a6ab..5e2108199 100644 --- a/packages/hoppscotch-web/src/main.ts +++ b/packages/hoppscotch-web/src/main.ts @@ -1,4 +1,5 @@ import { createHoppApp } from "@hoppscotch/common" +import { initializeFirebase } from "./firebase/init" import { def as authDef } from "./firebase/auth" import { def as envDef } from "./environments" import { def as collectionsDef } from "./collections" @@ -7,6 +8,8 @@ import { def as historyDef } from "./history" import { def as tabStateDef } from "./tab" import { def as analyticsDef } from "./analytics" +initializeFirebase() + createHoppApp("#app", { auth: authDef, analytics: analyticsDef,