Skip to content
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

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

freiksenet
Copy link
Contributor

@freiksenet freiksenet commented Jun 3, 2020

Value can be anything, not just string.

Closes #23852

@freiksenet freiksenet requested a review from a team as a code owner June 3, 2020 08:48
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 3, 2020
@freiksenet freiksenet changed the title Update documentation for createNodeField chore(docs): Update documentation for createNodeField Jun 3, 2020
@@ -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
Copy link
Contributor

@vladar vladar Jun 3, 2020

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:

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@vladar vladar left a 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.

@vladar vladar added type: documentation An issue or pull request for improving or updating Gatsby's documentation and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 3, 2020
@freiksenet freiksenet added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jun 18, 2020
@gatsbybot gatsbybot merged commit c884b0d into master Jun 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the create-node-field-docs branch June 18, 2020 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes type: documentation An issue or pull request for improving or updating Gatsby's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

createNodeField documentation falsely(?) claims that field values must be strings
3 participants