ExpressionAttributeValues must not be empty in graphQL with Gatsby
See original GitHub issueDescription
I’m using Gatsby with the below plugin.
"gatsby": "^2.21.0",
"gatsby-source-graphql": "^2.7.6",
When I use GraphQL, I got this error. I researched a solution, I couldn’t any hints.
ExpressionAttributeValues must not be empty (Service: DynamoDb, Status Code: 400, Request ID: 8A2PS0BPLA5RB1869L21ONB0NJVV4KQNSO5AEMVJF66Q9ASUAAJG, Extended Request ID: null)
The GraphQL is below.
###[./src/pages/profile.js]
.....
export const query = graphql`
query GetSingleProfile($slug: String) {
DynamoDB {
listBlrUsermatchs(filter: {slug: {eq: $slug}}) {
items {
id
imgUrl
imgUrlS3
kinds
languagesSpoken
location
name
.......
}
}
}
}
`
.....
I have below in gatsby-node.js.
###[gatsby-node.js.]
const usermatches = await graphql(`
{
usermatches: DynamoDB {
listBlrUsermatchs {
items {
slug
state
city
category
}
}
}
}
`)
usermatches.data.usermatches.listBlrUsermatchs.items.forEach(data => {
// Make Category
var category = '';
data.category.map((p) => {
category = category + '-' + p;
})
const state = data.state[0].replace(' ', '-').toLowerCase();
const city = data.city.replace(' ', '-').toLowerCase();
category = category.substring(1);
const uri = category + '/' + state + '/' + city + '/' + data.slug;
createPage({
path: `/${uri}`,
component: path.resolve(`./src/pages/profile.js`),
context: {
slug: data.slug
},
});
});
I want to pash a ‘slug’ that is defined in getsby-node.js tho, it might cause the problem. When I use a fixed value (like a ‘programer’ ) instead of $slug in profile.js, it goes well. And also, although I get the error, the program works.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
node.js - ExpressionAttributeValues must not be empty in ...
But am getting Validation Exception stating ExpressionAttributeValues must not be empty. Iam just assigning the interface to vehicleInfo
Read more >Troubleshooting Common Errors - Gatsby
This error message Field "image" must not have a selection since type "String" has no subfields. comes up when a GraphQL query is...
Read more >Handle empty results in a Gatsby source plug-in | Anton Ball
I don't understand how and the build fails because the query has no results. Do you create an empty node in Graphql? Is...
Read more >GatsbyJS + Drupal: Create Custom GraphQL Schema for ...
For the remainder of this post I will refer to GraphQL nodes as "nodes" and Drupal ... However, empty data in the source...
Read more >Gatsby, GraphQL and the Missing But Necessary Explanation ...
This works perfectly when all the data that has been queried and all your fields are filled with non-empty data, if we have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for opening this, @uekyo
The problem is that you’ve placed your template in
src/pages
folder: https://gitlab.com/kyo.ueda/bug-repro-gatsby-slug/-/blob/master/src/pages/places.jsGatsby creates pages for all files in
src/pages
folder automatically. But it executes queries from those files without any variables. And that’s why you see this error. If you move your template file fromsrc/pages/places.js
tosrc/templates/places.js
and update the path increatePages
API it works as expected.We’re marking this issue as answered and closing it for now but please feel free to reopen this and comment if you would like to continue this discussion. We hope we managed to help and thank you for using Gatsby! 💜
Have you tried running the same query against your remote GraphQL endpoint directly (with
slug
as a variable):I am a bit suspicious about the
filter
part here:listBlrUsermatchs(filter: {slug: {eq: $slug}})
. It looks like a Gatsby filter.Also to clarify: the error you’ve posted comes from your remote GraphQL API not from Gatsby, that’s why I am asking.