Skip to content

Commit e912c94

Browse files
committed
Properly type Config query use in environment.ts
1 parent f936b48 commit e912c94

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

Diff for: codegen.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
schema: './node_modules/@nft/api-graphql/schema.graphql'
22
documents:
3-
- './pages/**/*.gql'
4-
- './components/**/*.gql'
5-
- './layouts/**/*.gql'
6-
- './hooks/**/*.gql'
3+
- './*.{ts,tsx,gql}'
4+
- './pages/**/*.{ts,tsx,gql}'
5+
- './components/**/*.{ts,tsx,gql}'
6+
- './layouts/**/*.{ts,tsx,gql}'
7+
- './hooks/**/*.{ts,tsx,gql}'
78
generates:
89
graphql.ts:
910
plugins:

Diff for: environment.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import request from 'graphql-request'
1+
import type { ConfigQuery, ConfigQueryVariables } from 'graphql'
2+
import request, { gql } from 'graphql-request'
23
import { LRUCache } from 'lru-cache'
34
import { createContext } from 'react'
45
import invariant from 'ts-invariant'
56
import {
7+
Chain,
68
arbitrum,
79
arbitrumSepolia,
810
bsc,
911
bscTestnet,
10-
Chain,
1112
mainnet as ethereumMainnet,
1213
sepolia as ethereumSepolia,
1314
neonDevnet,
@@ -180,23 +181,25 @@ const cache = new LRUCache({
180181
: 0, // no ttl, user need to refresh the page
181182
fetchMethod: async (key: string) => {
182183
invariant(key === 'config', 'Invalid key')
183-
const { config } = await request<{ config: RemoteConfig }>(
184+
const { config } = await request<ConfigQuery, ConfigQueryVariables>(
184185
`${
185186
process.env.NEXT_PUBLIC_LITEFLOW_BASE_URL || 'https://api.liteflow.com'
186187
}/${process.env.NEXT_PUBLIC_LITEFLOW_API_KEY}/graphql`,
187-
`query Config {
188-
config {
189-
name
190-
hasLazyMint
191-
maxRoyaltiesPerTenThousand
192-
offerValiditySeconds
193-
metadata
188+
gql`
189+
query Config {
190+
config {
191+
name
192+
hasLazyMint
193+
maxRoyaltiesPerTenThousand
194+
offerValiditySeconds
195+
metadata
196+
}
194197
}
195-
}`,
198+
`,
196199
undefined,
197200
[['origin', process.env.NEXT_PUBLIC_BASE_URL || '']],
198201
)
199-
return config
202+
return config satisfies RemoteConfig
200203
},
201204
})
202205

0 commit comments

Comments
 (0)