-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
chore(docs): Update documentation for createNodeField #24740
Conversation
@@ -963,7 +963,7 @@ type CreateNodeInput = { | |||
* @param {string} $0.fieldName [deprecated] the name for the field | |||
* @param {string} $0.fieldValue [deprecated] the value for the field | |||
* @param {string} $0.name the name for the field | |||
* @param {string} $0.value the value for the field | |||
* @param {any} $0.value the value for the field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we actually sanitize it to this set of types:
gatsby/packages/gatsby/src/db/sanitize-node.js
Lines 62 to 75 in 2b578e8
const isTypeSupported = data => { | |
if (data === null) { | |
return true | |
} | |
const type = typeof data | |
const isSupported = | |
type === `number` || | |
type === `string` || | |
type === `boolean` || | |
data instanceof Date | |
return isSupported | |
} |
Not sure if we should change any
to this union though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand they can pass anything here indeed. It will be simply stripped away unless it's null | number | string | boolean | Date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can also be a plain object or array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Added one comment inline but up to you.
Value can be anything, not just string.
Closes #23852