Closed korukugashi closed 5 years ago
Is your project open source?
Unfortunately not.
Below is an example that reproduce the issue: example.zip
There is some test data in InsertExampleData.sql to import into a database
The example reproduces the problem well when all values are null, but not when a row is not null unlike my project, I will look for the difference
Assuming new_sma_id
is a String, try adding the following in your gatsby-node.js
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions;
const typeDefs = [
`type MysqlNewProduct implements Node {
new_sma_id: String
}`,
// add other type definition here that have the same null value scenario
];
createTypes(typeDefs);
}
Let me know if this solve your problem, else let me know what's the message you're seeing.
Great, it seems to work, thanks! I don't understand why that wasn't the case earlier, maybe it was clean gatsby
that was required..
In my project I have to define in the Type all the columns even those that are never null, however in the example project it works well by defining only the columns that are null... I will look for the differences.
I had a typo previously, it should be in gatsby-node.js
, not gatsby-config.js
.
Hi,
I am facing an issue with the management of null values: when a SQL query sometimes returns the null value for a column, Gatsby returns a compilation error indicating that it does not find the GraphQL field matching to this column
I would expect Gatsby to return this field with a null value, otherwise I would have to modify all my SQL queries to add
IFNULL(mycolumn, "")
in theSELECT
statement to make sure that if we encounter a null value the field is still present. In addition in some cases we may need both values: NULL and empty string.Following gatsbyjs/gatsby#6800, I tried to defined a type on my query (see schema customization), but I didn't achieve to match my type with the query.
Do you have any idea? Thanks