-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled rejection with fields that have the same name but different types #25
Comments
I would call this expected, but not a great experience. Those errors are thrown in Gatsby core because we only have one overall "group" for Airtable. So we are essentially combining multiple Airtable sheets into one "sheet" in Gatsby, and Gatsby can't have mixed data. Assuming it hasn't changed from last I looked, it will decide the data type for each field based on the first data it receives. That being said, we need to decide if/how it's best to show this to the developer. We could add an option to make more than one "group", but that makes things more complex if you use the pretty APIs (e.g. |
If you take something like contentful source plugin as an example it splits the data into content types ie portfolio blog etc which you can then filter out on the create node page using the gatsby internal type whereas currently on the airtable plugin you have one internal type ‘airtable’
or you can query in graphql in the contentful example with allportfolio allblog etc
it would be better if the sheets were allocated there own query name instead of filtering allAirtable with table = portfolio instead map it to AllAirtablePortfolio etc etc. Hope this makes sense, unfortunately I don’t have enough coding experience to implement this myself.
…________________________________
From: Jacob Bolda <notifications@github.com>
Sent: Thursday, November 22, 2018 7:14 pm
To: jbolda/gatsby-source-airtable
Cc: Subscribed
Subject: Re: [jbolda/gatsby-source-airtable] Unhandled rejection with fields that have the same name but different types (#25)
I would call this expected, but not a great experience. Those errors are thrown in Gatsby core because we only have one overall "group" for Airtable. So we are essentially combining multiple Airtable sheets into one "sheet" in Gatsby, and Gatsby can't have mixed data. Assuming it hasn't changed from last I looked, it will decide the data type for each field based on the first data it receives.
That being said, we need to decide if/how it's best to show this to the developer. We could add an option to make more than one "group", but that makes things more complex if you use the pretty APIs (e.g. onCreateNode). Or perhaps we just search for this in our code and through a more appropriate error or warning rather than relying on the Gatsby core errors top five enough direction. Have any thoughts on how we should approach this? Would love a PR as well once we decide the best path forward 😍
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#25 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AL62eicteoyhDX0fRhzEoiVHcoh96e-Mks5uxveAgaJpZM4YsOSc>.
|
Hey guys, see my PR above - I'd come across this very issue myself in a fairly complicated Airtable build, and had intended to submit a PR a week or so ago! But here it is :) I went through a few iterations of this, but my fork of this is working very well now and should address the issues @chrisblow is seeing. As mentioned in the PR, this also addresses a few other things - happy to split it into multiple PRs if you'd prefer @jbolda. I also concur with @chrisblow around the comment "I was surprised that the field names conflict at all. Perhaps this could be avoided somehow.". The default setup is likely to trip a lot of people up going forward, and it feels like each table in Airtable should be split into its own node type. As mentioned in the PR, this also stops the fields getting mixed up in GraphiQL, so each table only has its own fields, which is a far better experience. Right now my version can't do this "globally", as this would require some kind of automatic inference of the correct type name for each table. That's problematic as it's preferable to use the singular form of the table name for the GraphQL node type name, but most people would probably name their Airtable tables in the plural form (well, I certainly do). We could use some kind of code to attempt to singularise the table names already fed in, but that felt a bit "magic" to me, and I preferred the idea of specifying each type in each table config. @chrisblow would be interested to hear if using this version solves your issues. |
Also, as @waywardm mentioned, the implementation in the pull request will also prevent you needing to even filter for the table name in GraphQL. Each type is just queried via |
Thanks for all the work @traversal ! I am hesitant to make this a default especially since it has always been this way. With v2, we are just better enabled to take it further so I suspect that is why we haven't bumped into these issues prior. Maybe this is something we discuss for v3 perhaps, but trying to generally keep the major version pegged with Gatsby core. Migration between a switch and as the default is pretty minimal if we do decide to go that route later. This seems to be the easiest fix compared to trying to catch errors and have the user change their Airtable columns. |
Hey @jbolda no problems at all, thank you too for the work on this plugin. It's really enabling me to use Airtable as a pretty solid CMS for Gatsby. If they'd add some kind of basic support for Markdown formatting, it'd be basically perfect, but I digress... :) Agreed on the defaults, as I don't want to break current installs. It's probably something where we can stress in the documentation that users should add the I'll make further comments related to the PR over there, thanks for reviewing. |
We finished out the PR, and have published it in a beta version of |
It's possible this is expected behavior somehow, or I'm configuring it wrong. Feedback welcome.
Problem
I have a base where different tables have the same field name, but different types. Sometimes (when one is an array/multiple choice and the other field is string/single choice) this is handled gracefully with a warning. But other times (when one is a number and one is a string) the error was an
unhandled rejection
that was difficult to track down.Temporary solution
I had to change the Airtable field types to match, and in the future I'll have to manually check to make sure that new field types don't conflict with any of the existing fields.
Better solutions
• I was surprised that the field names conflict at all. Perhaps this could be avoided somehow.
• Alternatively, I would expect there to always be a more friendly warning about conflicting types, not an unhandled rejection.
Extra details:
The friendly warning was like this:
This is what happens with
Array[string]
type (multiple choice) vs.String
(single choice) type conflicts.(Ideally this warning would include the name of both tables involved — currently it only shows one of the table names.)
The unhandled rejection:
This is what happens with a
Number
type vs.String
type conflict.The text was updated successfully, but these errors were encountered: