Files
Benjamin WoodruffandGitHub c518402e07 [ci] update relay-compiler to 21.0.1 (#95217)
We need to upgrade this because the ancient version of relay-compiler
that we were using didn't support arm64.
2026-06-30 01:27:24 +00:00

30 lines
813 B
TypeScript

import {
Environment,
type GraphQLResponse,
Network,
RecordSource,
Store,
} from 'relay-runtime'
async function fetchGraphQL(text, variables): Promise<GraphQLResponse> {
return new Promise((next) => {
const res = () => {
return next({ data: { viewer: { user: { id: '123', name: 'Foo' } } } })
}
setTimeout(res, 1000)
})
}
// Relay passes a "params" object with the query name and text. So we define a helper function
// to call our fetchGraphQL utility with params.text.
async function fetchRelay(params, variables) {
return await fetchGraphQL(params.text, variables)
}
// Export a singleton instance of Relay Environment configured with our network function:
export default new Environment({
network: Network.create(fetchRelay),
store: new Store(new RecordSource()),
})