Skip to content

Commit

Permalink
fix: support for other API key format from the graph explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenttaglia committed Oct 21, 2024
1 parent c5ca216 commit daf96b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/plugins/defaultsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ export const loadDefaultsConfig = async () => {
}
}

}

export function replaceAPI(string, apiKey){
return string.replace("[api-key]", apiKey).replace("{api-key}", apiKey);
}
10 changes: 5 additions & 5 deletions src/plugins/graphNetworkSubgraphClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadDefaultsConfig } from "./defaultsConfig";
import { loadDefaultsConfig, replaceAPI } from "./defaultsConfig";
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'

const defaultsConfigVariables = await loadDefaultsConfig();
Expand All @@ -8,22 +8,22 @@ console.log(defaultsConfig.subgraphArbitrum);
// HTTP connection to the API
const httpLink = createHttpLink({
// You should use an absolute URL here
uri: defaultsConfig.subgraphMainnet.replace("[api-key]", defaultsConfig.apiKey),
uri: replaceAPI(defaultsConfig.subgraphMainnet, defaultsConfig.apiKey),
});

const arbitrumHttpLink = createHttpLink({
// You should use an absolute URL here
uri: defaultsConfig.subgraphArbitrum.replace("[api-key]", defaultsConfig.apiKey),
uri: replaceAPI(defaultsConfig.subgraphArbitrum, defaultsConfig.apiKey),
});

const sepoliaHttpLink = createHttpLink({
// You should use an absolute URL here
uri: defaultsConfig.subgraphSepolia.replace("[api-key]", defaultsConfig.apiKey),
uri: replaceAPI(defaultsConfig.subgraphSepolia, defaultsConfig.apiKey),
});

const arbitrumSepoliaHttpLink = createHttpLink({
// You should use an absolute URL here
uri: defaultsConfig.subgraphArbitrumSepolia.replace("[api-key]", defaultsConfig.apiKey),
uri: replaceAPI(defaultsConfig.subgraphArbitrumSepolia, defaultsConfig.apiKey),
});

// Cache implementation
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/qosSubgraphClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadDefaultsConfig } from "./defaultsConfig";
import { loadDefaultsConfig, replaceAPI } from "./defaultsConfig";
import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client/core'

const defaultsConfigVariables = await loadDefaultsConfig();
Expand All @@ -7,7 +7,7 @@ const defaultsConfig = defaultsConfigVariables.variables;
// HTTP connection to the API
const httpLink = createHttpLink({
// You should use an absolute URL here
uri: defaultsConfig.qosSubgraph.replace("[api-key]", defaultsConfig.apiKey),
uri: replaceAPI(defaultsConfig.qosSubgraph, defaultsConfig.apiKey),
});

const cache = new InMemoryCache();
Expand Down

0 comments on commit daf96b8

Please sign in to comment.