From 790a660833c74050b781dd17dc8bc4b97f5d915d Mon Sep 17 00:00:00 2001 From: Spacebean Date: Sat, 14 Sep 2024 12:49:16 -0600 Subject: [PATCH] update subgraph functions + envs --- projects/ui/codegen-individual.yml | 33 +++++++++++++++++ projects/ui/src/graph/client.ts | 59 ++++++++++++++++++++++++++++++ projects/ui/src/graph/endpoints.ts | 53 +++++++++++++++++++++++++++ 3 files changed, 145 insertions(+) diff --git a/projects/ui/codegen-individual.yml b/projects/ui/codegen-individual.yml index cae7276cba..9c6f224a5c 100644 --- a/projects/ui/codegen-individual.yml +++ b/projects/ui/codegen-individual.yml @@ -28,3 +28,36 @@ generates: - https://graph.node.bean.money/subgraphs/name/beanft plugins: - "schema-ast" + + + +# # Use this file to generate schemas for individual subgraphs. +# # This is particularly useful when a schema that isn't in production needs to be used. +# # A more optimal solution would involve generating a different schema for each entry in src/graph.endpoints.ts. +# overwrite: true +# generates: +# ./src/graph/schema-beanstalk.graphql: +# schema: +# - https://graph.bean.money/beanstalk +# plugins: +# - "schema-ast" +# ./src/graph/schema-bean.graphql: +# schema: +# - https://graph.bean.money/bean +# plugins: +# - "schema-ast" +# ./src/graph/schema-snapshot1.graphql: +# schema: +# - https://hub.snapshot.org/graphql +# plugins: +# - "schema-ast" +# #./src/graph/schema-snapshot2.graphql: +# # schema: +# # - https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot +# # plugins: +# # - "schema-ast" +# ./src/graph/schema-beanft.graphql: +# schema: +# - https://graph.node.bean.money/subgraphs/name/beanft +# plugins: +# - "schema-ast" diff --git a/projects/ui/src/graph/client.ts b/projects/ui/src/graph/client.ts index 86186ad7a4..fac337ff42 100644 --- a/projects/ui/src/graph/client.ts +++ b/projects/ui/src/graph/client.ts @@ -213,3 +213,62 @@ export const apolloClient = new ApolloClient({ ), cache, }); + + + +// // L2 subgraphs +// const beanstalkLink = new HttpLink({ +// uri: sgEnv.subgraphs.beanstalk, +// }); + +// const beanLink = new HttpLink({ +// uri: sgEnv.subgraphs.bean, +// }); + +// // L1 subgraphs +// const beanstalkEthLink = new HttpLink({ +// uri: sgEnv.subgraphs.beanstalk_eth, +// }); + +// const beanEthLink = new HttpLink({ +// uri: sgEnv.subgraphs.bean_eth, +// }); + +// const snapshotLink = new HttpLink({ +// uri: 'https://hub.snapshot.org/graphql', +// headers: { +// 'x-api-key': SNAPSHOT_API_KEY, +// }, +// }); + +// const snapshotLabsLink = new HttpLink({ +// uri: `https://gateway-arbitrum.network.thegraph.com/api/${import.meta.env.VITE_THEGRAPH_API_KEY}/subgraphs/id/5MkoYVE5KREBTe2x45FuPdqWKGc2JgrHDteMzi6irSGD`, +// }); + +// /// ///////////////////////// Client //////////////////////////// + +// export const apolloClient = new ApolloClient({ +// connectToDevTools: true, +// link: ApolloLink.split( +// (operation) => operation.getContext().subgraph === 'bean_eth', +// beanEthLink, // true +// ApolloLink.split( +// ({ getContext }) => getContext().subgraph === 'beanstalk_eth', +// beanstalkEthLink, // true +// ApolloLink.split( +// ({ getContext }) => getContext().subgraph === 'snapshot', +// snapshotLink, // true +// ApolloLink.split( +// ({ getContext }) => getContext().subgraph === 'snapshot-labs', +// snapshotLabsLink, // true +// ApolloLink.split( +// ({ getContext }) => getContext().subgraph === 'bean', +// beanLink, // true +// beanstalkLink // false +// ) +// ) +// ) +// ) +// ), +// cache, +// }); \ No newline at end of file diff --git a/projects/ui/src/graph/endpoints.ts b/projects/ui/src/graph/endpoints.ts index 309d045732..8f06003b37 100644 --- a/projects/ui/src/graph/endpoints.ts +++ b/projects/ui/src/graph/endpoints.ts @@ -66,3 +66,56 @@ export const SUBGRAPH_ENVIRONMENTS: Record = { }, }, }; + + +// export enum SGEnvironments { +// BF_PROD = 'bf-prod', +// BF_DEV = 'bf-dev', +// BF_TEST = 'bf-test', +// } + +// type SGEnvironment = { +// name: string; +// subgraphs: { +// beanstalk: string; +// bean: string; +// // beanft: string; +// beanstalk_eth: string; +// bean_eth: string; +// }; +// }; + +// const ENDPOINT = 'https://graph.bean.money'; + +// export const SUBGRAPH_ENVIRONMENTS: Record = { +// [SGEnvironments.BF_PROD]: { +// name: 'Beanstalk Farms / Production', +// subgraphs: { +// beanstalk: `${ENDPOINT}/beanstalk`, +// bean: `${ENDPOINT}/bean`, +// beanstalk_eth: `${ENDPOINT}/beanstalk_eth`, +// bean_eth: `${ENDPOINT}/bean_eth`, +// }, +// }, +// [SGEnvironments.BF_DEV]: { +// name: 'Beanstalk Farms / Development', +// subgraphs: { +// beanstalk: `${ENDPOINT}/beanstalk-dev`, +// bean: `${ENDPOINT}/bean-dev`, +// beanstalk_eth: `${ENDPOINT}/beanstalk-dev_eth`, +// bean_eth: `${ENDPOINT}/bean-dev_eth`, +// }, +// }, +// [SGEnvironments.BF_TEST]: { +// name: 'Beanstalk Farms / Test', +// subgraphs: { +// beanstalk: `${ENDPOINT}/beanstalk-testing`, +// bean: `${ENDPOINT}/bean-testing`, +// beanstalk_eth: `${ENDPOINT}/beanstalk-testing_eth`, +// bean_eth: `${ENDPOINT}/bean-testing_eth`, +// }, +// }, +// }; + +// // keeping as reference +// // beanft: 'https://graph.node.bean.money/subgraphs/name/beanft', \ No newline at end of file