Disable build-time fetching in CI environment? #24554
-
Hey, I've got a project which has a GraphQL-backend from which it gets props in getStaticProps (fully static pages) on which I'd like to run some tests and build in isolation. Right now my builds fail because of I was hoping there would be an environment variable or config setting I could use to bypass data fetching. Perhaps just a environment variable and if that's set, return an empty props object(?). Does anyone have any experience with a similar situation? Maybe the solution to spin up a mock graphql backend in the CI environment? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Why you can't do this inside getStaticProps? Maybe also some error control when you're using other code to catch/login data, so your build will not crash. export const getStaticProps: GetStaticProps = async () => {
const data = await getData;
if(data)
return {
propsData
};
} else {
return {
propsWithoutData
};
} |
Beta Was this translation helpful? Give feedback.
Why you can't do this inside getStaticProps? Maybe also some error control when you're using other code to catch/login data, so your build will not crash.