wp-graphql / wp-graphql-acf

WPGraphQL for Advanced Custom Fields
https://wpgraphql.com/acf
626 stars 123 forks source link

ACF Datetime fields return as null #108

Closed sirichards closed 4 years ago

sirichards commented 4 years ago

Hey,

I have an issue where ACF date time picker fields are returned as null in GraphQL.

2

Data comes through in the rest API.

3

Could be related to #18

Hansanghyeon commented 4 years ago

I get this error in the value for a datetime field and return null.

jasonbahl commented 4 years ago

@Hansanghyeon what error do you get? It looks like the image you tried to add doesn't exist.

jasonbahl commented 4 years ago

@sirichards I'm unable to replicate this behavior.

I created an ACF Field Group with a Date Picker, DateTime Picker, and Time Picker, and saved a post with values.

Screen Shot 2020-03-31 at 5 04 26 PM

I then query the Post in GraphQL, and get the values returned:

Screen Shot 2020-03-31 at 5 04 09 PM

Can you provide more information so I can replicate?

Hansanghyeon commented 4 years ago

Tested again. I have confirmed that the date field works without problems. Thank you. 🙏

jasonbahl commented 4 years ago

Thanks for the follow-up @Hansanghyeon!

benleeth commented 4 years ago

I, too, am having this issue but only in the Options.

Localhost GraphiQL alt text

GUI GraphiQL alt text

Options page alt text

DB alt text

WordPress 5.3.2 WP GraphQL 0.8.0 WPGraphQL for Advanced Custom Fields 0.3.1

jasonbahl commented 4 years ago

@benleeth looking into this 👀

benleeth commented 4 years ago

@jasonbahl, thanks!

jasonbahl commented 4 years ago

@benleeth have a PR here (https://github.com/wp-graphql/wp-graphql-acf/pull/125) that I believe addresses this.

I have a test Post with a datetime field and a flex field with a datetime within it:

Screen Shot 2020-04-16 at 8 59 18 PM

I also setup an options page similar to yours:

Screen Shot 2020-04-16 at 8 52 55 PM

Below are the queries I tried:

Before

Screen Shot 2020-04-16 at 8 57 57 PM

After

Screen Shot 2020-04-16 at 8 56 58 PM

jasonbahl commented 4 years ago

@benleeth this fix has been released in v0.3.2

adeluleye commented 4 years ago

@jasonbahl Thanks for this release of v0.3.2. I was initially having issue querying a date picker field with v0.3.1 as I always get an Internal Server Error. When I updated to v0.3.2, the error stopped but I still get a wrong date returned.

Here are my screenshots:

Screenshot 2020-04-19 at 10 34 14 AM Screenshot 2020-04-19 at 10 39 15 AM

Any idea why i keep getting same date of 22/08/1970?

I'm using WPGraphQL 0.4.1, I have also tried 0.8.3 but same behavior WPGraphQL ACF 0.3.2 ACF Pro 5.8.3 WordPress version: using 4.8.2 before when I got that behavior, upgraded to 5.4 and still same issue.

jasonbahl commented 4 years ago

gah!

I'll see what I can find out.

stephanedemotte commented 4 years ago

@jasonbahl any update on this ?

jasonbahl commented 4 years ago

@stephanedemotte try v0.3.3

https://github.com/wp-graphql/wp-graphql-acf/releases/tag/v0.3.3

JorgeSivil commented 6 months ago

I'm sorry to revive an old thread but I wanted to contribute my bug since this is one of the first google results

in the ACF php definition we had this

'return_format' => 'YYYY-MM-DD'

which was causing the field to always return null

I changed it to 'return_format' => 'Y-m-d', and it fixed the issue