question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getResourceFromContext returns null result during build

See original GitHub issue

I’m currently facing an issue while running & building my project. My Drupal backend is running as a container in an Azure Web App. Pages are generated within getStaticProps.

const apiResource: JsonApiResource = await getResourceFromContext(type, context);

Type and context parameters are set correctly, but the result is always null. Below you’ll find an example output of some console.log statements

type taxonomy_term--category

context

{
  params: { slug: [ 'category', 'interviews' ] },
  locales: undefined,
  locale: undefined,
  defaultLocale: undefined
}

apiResource null

I use the code from above in a page named [...slug].tsx

When I run or build my NextJS project with a local Drupal backend, all contents are fetched and queried correctly.

Am I missing something in my NextJS configuration, when working with a remote backend or is the issue more related to my web app security and networking settings?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
shadcncommented, Jun 10, 2022

@kretzschr Since this bug came up a few times, I backported the fix and created a new release.

Can you upgrade to next-drupal 1.4-rc1 and test please?

Note: I’d still recommend the DrupalClient going forward.

Thank you.

1reaction
shadcncommented, Jun 10, 2022

@kretzschr It looks like you’re hitting the same issue @Kroonax as mentioned here: https://github.com/chapter-three/next-drupal/issues/227#issuecomment-1152079200.

Is it possible to upgrade to the DrupalClient?

(I’ll also be patching this in the 1.4 release)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't access resource variable using ... - GitHub
Can't access resource variable using GetResourceFromContext in a custom op, probably because of binary incompatibility #25113.
Read more >
Android get resource from context's theme programmatically ...
I split my code into two project to have some kind of SDK with functionalities common to all my future projects. So I'm...
Read more >
Building Pages - Next.js for Drupal
How to build pages using JSON:API resources from Drupal. In Next.js, you fetch server-side data in either getStaticProps or getServerSideProps . Data is...
Read more >
How to progressively decouple your Drupal site with Next.js ...
This is why we built next-drupal for progressive adoption: decouple your Drupal site page by page, content type by content type, one at...
Read more >
How do I get Android string resources for flutter package?
resName)) } return context.getString(stringRes) } } }. Then when you need any string from resources, you can call getResourceFromContext method, for example ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found