RevereCRE / relay-nextjs

⚡️ Relay integration for Next.js apps
https://reverecre.github.io/relay-nextjs/
MIT License
250 stars 30 forks source link

nested dynamic routes - how to get the right variable #33

Closed philipbalbas closed 2 years ago

philipbalbas commented 2 years ago

I have this route /chapter/[chapterSlug]/topic/[topicSlug] however the preloadedQuery passes both the chapterSlug and topicSlug to the query. How do I make it so that only topicSlug is passed.

rrdelaney commented 2 years ago

Configuring variablesFromContext on that page should do the trick!

Something like:

export default withRelay(MyPage, {
  /* ... */
  variablesFromContext: ctx => ({ topicSlug: ctx.query.topicSlug }),
});
philipbalbas commented 2 years ago

thanks that did the trick