Closed boulaffasae closed 4 years ago
Hi @boulaffasae !
Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.
If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.
Thanks for using Gatsby! 💜
Hi @TylerBarnes,
I created a test repo Going Headless with Gatsby & Drupal.
After install, head over to drupal
directory and:
ddev drush en media -y
Add a new Media field to Content type Article at /admin/structure/types/manage/article/fields/add-field
Update or create an article and upload an image to your new Media field
Now head over to http://localhost:8000/___graphql
after running gatsby develop
in gatsby
directory, and execute the following query:
{
allNodeArticle {
edges {
node {
title
created(formatString: "DD MMMM YYYY")
relationships {
field_media_image {
localFile {
childImageSharp {
fluid(maxWidth: 760, maxHeight: 570) {
...GatsbyImageSharpFluid
}
}
}
}
}
}
}
}
}
Query will raise error:
{
"errors": [
{
"message": "Cannot query field \"localFile\" on type \"media__image\".",
"locations": [
{
"line": 9,
"column": 13
}
],
"stack": [
"GraphQLError: Cannot query field \"localFile\" on type \"media__image\".",
" at Object.Field (/home/user/Documents/gatsby-drupal/gatsby/node_modules/graphql/validation/rules/FieldsOnCorrectType.js:53:31)",
" at Object.enter (/home/user/Documents/gatsby-drupal/gatsby/node_modules/graphql/language/visitor.js:324:29)",
" at Object.enter (/home/user/Documents/gatsby-drupal/gatsby/node_modules/graphql/language/visitor.js:375:25)",
" at visit (/home/user/Documents/gatsby-drupal/gatsby/node_modules/graphql/language/visitor.js:242:26)",
" at validate (/home/user/Documents/gatsby-drupal/gatsby/node_modules/graphql/validation/validate.js:73:24)",
" at /home/user/Documents/gatsby-drupal/gatsby/node_modules/express-graphql/index.js:121:32",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"
]
}
]
}
Hi @TylerBarnes, @smthomas
I found that using Media Module, a user need to query the relationships
inside the media field, and that the media field itself does not have a uri
or url
.
And that my prb is related to File Entity module, and not Media module.
The File Entity module extends the core file entity and somehow he change file--file
to file--image
. But gatsby-source-drupal
download only fields with type file--file
.
File entity provides interfaces for managing files. It also extends the core file entity, allowing files to be fieldable, grouped into types, viewed (using display modes) and formatted using field formatters. File entity integrates with a number of modules, exposing files to Views, Entity API, Token and more.
Sorry 😞
I'm running into same issues on a site with gatsby 3.x...
query MyQuery {
allNodeArticle(limit: 1, sort: {fields: created, order: DESC}) {
group(field: id) {
edges {
node {
id
}
}
}
edges {
node {
title
relationships {
field_featured_image {
relationships {
field_media_image {
uri {
url
}
}
}
}
}
}
}
}
}
Image shows there but I am not longer able to use this bit:
localFile {
childImageSharp {
fluid(maxWidth: 760, maxHeight: 570) {
...GatsbyImageSharpFluid
}
}
}
Same error: Cannot query field localFile on type media__image.
Nvm... Everything works fine... I failed...
I had config: skipFileDownloads: true,
Description
Cannot query field
localFile
on typemedia__image
.Steps to reproduce
field_media_image
inArticle
, chooseMedia: Image
.localFile
infield_media_image
.Expected result
Querying field
localFile
on typemedia__image
, and downloading files.Actual result
Cannot query field
localFile
on typemedia__image
, and therefore no option to download files.Environment