Created
January 5, 2024 17:44
-
-
Save noghartt/a2c6a8ac8501231994a57875c84e520f to your computer and use it in GitHub Desktop.
fetchQuery relay toPromise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fetchQuery, graphql } from 'relay-runtine'; | |
export const fetchVersion = async (environment) => { | |
const response = fetchQuery( | |
environment, | |
graphql` | |
query fetchVersionQuery { | |
version | |
} | |
`, | |
{} | |
).toPromise(); | |
return await fetchVersion(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createMockEnvironment } from 'relay-test-utils'; | |
import { fetchVersion } from ' | |
it('should get the version from graphql query', async () => { | |
const environment = createMockEnvironment(); | |
await fetchVersion(environment); // timeout here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
missing mock of the query