1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

added back apollo typings until we can get all of them using graphql codegen

This commit is contained in:
Bogdan Fazakas 2021-07-09 11:36:43 +03:00
parent d250da3eab
commit 11b7146812
12 changed files with 4107 additions and 48 deletions

10
apollo.config.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
client: {
service: {
name: 'ocean',
url: 'https://subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
// optional disable SSL validation check
skipSSLValidation: true
}
}
}

View File

@ -8,7 +8,10 @@ execSync(`node ./scripts/write-repo-metadata > repo-metadata.json`, {
})
// Generate GraphQl typings for urql
execSync(`npm run graphql:graphTypes`, { stdio: 'inherit' })
// execSync(`npm run graphql:graphTypes`, { stdio: 'inherit' })
// Generate Apollo typings
execSync(`npm run apollo:codegen`, { stdio: 'inherit' })
// Fetch EVM networks metadata
execSync(

4085
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,8 @@
"build": "gatsby build && cp _redirects public/_redirects",
"serve": "serve -s public/",
"jest": "NODE_ENV=test jest -c tests/unit/jest.config.js",
"test": "npm run graphql:graphTypes && npm run lint && npm run jest",
"test-graphql": "npm run graphql:graphTypes && npm run lint && npm run jest",
"test": "npm run apollo:codegen && npm run lint && npm run jest",
"test:watch": "npm run lint && npm run jest -- --watch",
"lint": "npm run write:repoMetadata && eslint --ignore-path .gitignore --ext .js --ext .ts --ext .tsx . && npm run type-check",
"format": "prettier --ignore-path .gitignore './**/*.{css,yml,js,ts,tsx,json}' --write",
@ -20,6 +21,7 @@
"write:repoMetadata": "node ./scripts/write-repo-metadata > repo-metadata.json",
"deploy:s3": "./scripts/deploy-s3.sh",
"postinstall": "husky install",
"apollo:codegen": "apollo client:codegen --target typescript --tsFileExtension=d.ts --outputFlat src/@types/apollo/",
"graphql:graphTypes": "graphql-codegen --config codegen.yml"
},
"dependencies": {
@ -114,6 +116,7 @@
"@types/yup": "^0.29.11",
"@typescript-eslint/eslint-plugin": "^4.26.0",
"@typescript-eslint/parser": "^4.26.0",
"apollo": "^2.33.4",
"eslint": "^7.27.0",
"eslint-config-oceanprotocol": "^1.5.0",
"eslint-config-prettier": "^8.3.0",

View File

@ -9,10 +9,13 @@ import { useUserPreferences } from '../../providers/UserPreferences'
import { Ocean } from '@oceanprotocol/lib'
import { formatPrice } from '../atoms/Price/PriceUnit'
import { gql, useQuery } from 'urql'
import {
TransactionHistory,
TransactionHistory_poolTransactions as TransactionHistoryPoolTransactions
} from '../../@types/apollo/TransactionHistory'
import web3 from 'web3'
import { useWeb3 } from '../../providers/Web3'
import { getOceanConfig } from '../../utils/ocean'
const txHistoryQueryByPool = gql`
query TransactionHistoryByPool($user: String, $pool: String) {

View File

@ -6,6 +6,7 @@ import Price from '../../atoms/Price'
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
import { useAsset } from '../../../providers/Asset'
import { gql, useQuery } from 'urql'
import { OrdersData } from '../../../@types/apollo/OrdersData'
import BigNumber from 'bignumber.js'
import { useOcean } from '../../../providers/Ocean'
import { useWeb3 } from '../../../providers/Web3'

View File

@ -18,6 +18,7 @@ import Button from '../../../atoms/Button'
import { Logger } from '@oceanprotocol/lib'
import { useAsset } from '../../../../providers/Asset'
import { gql, useQuery } from 'urql'
import { PoolHistory } from '../../../../@types/apollo/PoolHistory'
declare type GraphType = 'liquidity' | 'price'

View File

@ -16,6 +16,7 @@ import Transactions from './Transactions'
import Graph from './Graph'
import { useAsset } from '../../../../providers/Asset'
import { gql, useQuery } from 'urql'
import { PoolLiquidity } from '../../../../@types/apollo/PoolLiquidity'
import { useOcean } from '../../../../providers/Ocean'
import { useWeb3 } from '../../../../providers/Web3'

View File

@ -4,6 +4,7 @@ import ExplorerLink from '../../atoms/ExplorerLink'
import Time from '../../atoms/Time'
import styles from './EditHistory.module.css'
import { gql, useQuery } from 'urql'
import { ReceiptData_datatokens_updates as ReceiptData } from '../../../@types/apollo/ReceiptData'
import { useWeb3 } from '../../../providers/Web3'
const getReceipts = gql`

View File

@ -9,6 +9,7 @@ import Table from '../../../atoms/Table'
import Button from '../../../atoms/Button'
import { useOcean } from '../../../../providers/Ocean'
import { gql, useQuery } from 'urql'
import { ComputeOrders } from '../../../../@types/apollo/ComputeOrders'
import { useWeb3 } from '../../../../providers/Web3'
import {
queryMetadata,

View File

@ -4,6 +4,11 @@ import Conversion from '../../atoms/Price/Conversion'
import styles from './PoolShares.module.css'
import AssetTitle from '../../molecules/AssetListTitle'
import { gql, useQuery } from 'urql'
import {
PoolShares as PoolSharesList,
PoolShares_poolShares as PoolShare,
PoolShares_poolShares_poolId_tokens as PoolSharePoolIdTokens
} from '../../../@types/apollo/PoolShares'
import web3 from 'web3'
import Token from '../../organisms/AssetActions/Pool/Token'
import { useWeb3 } from '../../../providers/Web3'

View File

@ -3,10 +3,19 @@ import { DDO, BestPrice } from '@oceanprotocol/lib'
import { getUrqlClientInstance } from '../providers/UrqlProvider'
import { getOceanConfig } from './ocean'
import web3 from 'web3'
import { AssetsFreePrice } from '../@types/apollo/AssetsFreePrice'
import {
AssetsPoolPrice,
AssetsPoolPrice_pools as AssetsPoolPricePools
} from '../@types/apollo/AssetsPoolPrice'
import {
AssetsFrePrice,
AssetsFrePrice_fixedRateExchanges as AssetsFrePriceFixedRateExchanges
} from '../@types/apollo/AssetsFrePrice'
import {
AssetsFreePrice,
AssetsFreePrice_dispensers as AssetFreePriceDispenser
} from '../@types/apollo/AssetsFreePrice'
import { AssetPreviousOrder } from '../@types/apollo/AssetPreviousOrder'
// import {AssetPreviousOrder} from '../@types/graph.types'
// import { AssetFree } from '../@types/graph.types'
export interface PriceList {
[key: string]: string
@ -236,9 +245,9 @@ async function getAssetsPoolsExchangesAndDatatokenMap(
assets: DDO[]
): Promise<
[
ApolloQueryResult<AssetsPoolPrice>,
ApolloQueryResult<AssetsFrePrice>,
ApolloQueryResult<AssetsFreePrice>,
AssetsPoolPricePools[],
AssetsFrePriceFixedRateExchanges[],
AssetFreePriceDispenser[],
DidAndDatatokenMap
]
> {
@ -304,9 +313,9 @@ export async function getAssetsPriceList(assets: DDO[]): Promise<PriceList> {
const priceList: PriceList = {}
const values: [
ApolloQueryResult<AssetsPoolPrice>,
ApolloQueryResult<AssetsFrePrice>,
ApolloQueryResult<AssetsFreePrice>,
AssetsPoolPricePools[],
AssetsFrePriceFixedRateExchanges[],
AssetFreePriceDispenser[],
DidAndDatatokenMap
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)
const poolPriceResponse = values[0]
@ -356,7 +365,7 @@ export async function getPrice(asset: DDO): Promise<BestPrice> {
freVariables,
queryContext
)
const freePriceResponse: ApolloQueryResult<AssetsFreePrice> = await fetchData(
const freePriceResponse: OperationResult<AssetsFreePrice> = await fetchData(
AssetFreeQuery,
freeVariables,
queryContext
@ -377,9 +386,9 @@ export async function getAssetsBestPrices(
const assetsWithPrice: AssetListPrices[] = []
const values: [
ApolloQueryResult<AssetsPoolPrice>,
ApolloQueryResult<AssetsFrePrice>,
ApolloQueryResult<AssetsFreePrice>,
AssetsPoolPricePools[],
AssetsFrePriceFixedRateExchanges[],
AssetFreePriceDispenser[],
DidAndDatatokenMap
] = await getAssetsPoolsExchangesAndDatatokenMap(assets)