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

Unknown argument `formatString` #1567

Closed
ahmedelgabri opened this issue Jul 19, 2017 · 8 comments

Comments

@ahmedelgabri
Copy link
Member

commented Jul 19, 2017

If I try to use formatString on the date from frontmatter here, it shows this error

screen shot 2017-07-19 at 21 23 59

It doesn't work even in the graphql console

screen shot 2017-07-19 at 21 28 10

@secretfader

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2017

You might try formatting the date field to something a bit more standard and see if that helps. I've had intermittent issues with date fields before, and tweaking the formatting usually helps.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2017

Yeah, a string has to be a standard date format for the various date formatting options to be added.

@ahmedelgabri

This comment has been minimized.

Copy link
Member Author

commented Jul 19, 2017

cool, thanks @nicholaswyoung & @KyleAMathews

@daviddeejjames

This comment has been minimized.

Copy link
Contributor

commented Sep 30, 2017

@KyleAMathews If I am using this with the Wordpress REST API, how do I ensure its being returned as a string, looking at the example in the Gatsby repo it seems that it kinda just works?

EDIT: To clarify I receive a date without using the formatString function, however I get the error mentioned here when attempting to format it (including using GraphIQL console)

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Sep 30, 2017

Try using gatsby-source-wordpress which handles this for you.

@daviddeejjames

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2017

@KyleAMathews sorry I should have clarified I am using gatsby-source-wordpress and have created a blog page that uses the GraphQL query below. It works as intended! But would like to format the date without having to use something like MomentJS to format after the fact. However by adding the date(formatString: "MMMM DD, YY") that you have used in your Wordpress example, I am thrown the Unknown argument "formatString"

Any assistance with this issue would be greatly appreciated 👍

// Working Query
export const postQuery = graphql`
  query getPostQuery {
    allWordpressPost(sort: { fields: [date] }) {
      edges {
        node {
          id
          title
          excerpt
          slug
          date
        }
      }
    }
  }`
@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2017

This just means that for some reason the data in your "date" field doesn't look dates to Gatsby. You'll need to do some debugging to see what your data looks like. Also might want to add some console.logs here

e[key] = new Date(e[`${key}_gmt`] + `z`).toJSON()
Perhaps the WordPress API doesn't always include *_gmt fields.

@andrejarboe

This comment has been minimized.

Copy link

commented Mar 20, 2019

date must be: 2000-01-01
NOT: 2000-1-1

that was my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.