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.

gatsby-source-drupal - pull only nodes and menus?

See original GitHub issue

I’ve been through the issue queue and could not find any reference for that.

I have a Drupal installation that has the GrpahQL and JsonAPI module enabled. From what I saw, the gatsby-source-drupal plugin pulls from the JSON API only nodes, file, and menu entities. I have custom entities that appear in the JSON API endpoint but the grpahql explorer of my Gatsby ignores them.

Anything I’m missing? I also looked on the filters in plugin option but that did not do the trick as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
RoySegallcommented, Jun 11, 2020

@smthomas Permissions are correct. Since My drupal is only for gatsbyjs and some other microservices I did something like this:

/**
 * Implements hook_entity_access().
 */
function my_module_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {

  if ($operation != 'view') {
    // Not a view operation, skip this one.
    return;
  }

  if ($entity->getEntityType()->id() == 'user') {
    // Don't expose user via this hook.
    return;
  }

  // All entities, beside user, are allowed to be watched.
  return \Drupal\Core\Access\AccessResult::allowed();
}
1reaction
smthomascommented, Jun 6, 2020

I spent some time testing this locally and I was able to get other entities to show up correctly. A few things that need to be checked:

  • The cache sometimes needs to be cleared. At first my new entities did not show up until I ran a gatsby clean and cleared the Drupal cache
  • Permissions are important. I was not use a user/password in my gatsby-config.js and this made some entities not show up. For me, I was logged in locally so I could see all the entities at the /jsonapi endpoint. However, if I opened an incognito/private browsing window and went to the /jsonapi endpoint you might start seeing less data because of permissions. The solution is to make sure you use a user/password in your gatsby-config.js that has adequate permissions

I hope that helps. Let me know if you are still seeing the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-source-drupal
Source plugin for pulling data (including images) into Gatsby from Drupal sites. It pulls data from Drupal 8/9 sites with the Drupal JSONAPI...
Read more >
Source content from individual content pages rather than ...
Problem/Motivation Drupal doesn't cache the JSON:API list view very well. The individual pages are cleared much less often.
Read more >
gatsby-source-drupal-menu-links - npm
Integrates Drupal's jsonapi_menu_items module with Gatsby. Latest version: 3.0.1, last published: a year ago.
Read more >
Decoupled Drupal: Getting Started with Gatsby and JSON:API
Learn how to get up and running with decoupled Drupal using Gatsby and JSON:API.
Read more >
An introduction to Decoupled Drupal with Gatsby - Code Enigma
Restarting Gatsby allows the application to pull the data it needs from your Drupal site and generate the needed data for the pages...
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