-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor data fetching #1920
base: canary
Are you sure you want to change the base?
Refactor data fetching #1920
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
# Conflicts: # examples/magento-graphcms/pages/404.tsx # examples/magento-graphcms/pages/search/index.tsx # packages/graphql-mesh/package.json # packages/graphql/package.json # packages/magento-category/package.json # packages/magento-search/package.json # packages/magento-store/package.json # packages/next-ui/package.json # packagesDev/eslint-config/package.json # yarn.lock
Refactor the data fetching store to achieve a better abstraction.
Introduce
enhanceStaticProps(original)
,enhanceServiceSideProps(original)
,enhanceStaticProps(original)
functions which wrap the nextjs' defaultgetStaticProps
,getServerSideProps
andgetStaticPaths
functions respectively.This allows us to do quite a few things:
The
enhance*
methods leverage node.js' AsyncLocalStorage functionality to wrap all function calls in astorefrontContext
. Which allows users to usestorefrontConfig()
without passing any arguments.This means that we do not need to initialize the
graphqlSsrClient()
andgraphqlSharedClient()
with any arguments. Which in turn allows us to abstract away these methods tographqlQuery(query, options)
andgraphqlQueryPassToClient(query, options)
and move them to the library (because the extensibility is handled by plugins now #1915)Other notable changes:
Created a split in packages for shared components and server only components where most packages will have a secondary
/server
export. e.g.:@graphcommerce/magento-product/server
for methods are are meant to be only run on the server. (we might useimport 'server-only'
in these packages if nextjs supports it for the pages directory)Removed
legacyProductRoute
configuration + removed thepages/product/*
files + removed the ProductPage query. We're now fully migrated to the recentp/[url]
route.