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

Replace DateQueryInput with strings for the dateQuery before and afte… #1239

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kellenmace
Copy link
Contributor

…r fields so that strtotime()-compatible strings can be passed in

What does this implement/fix? Explain your changes.

Replaces DateQueryInput with strings for the dateQuery before and after fields so that strtotime()-compatible strings can be passed in.

Test query:

query {
  posts(first: 10, where: {
    dateQuery: {
      after: "2020-03-13T19:05:30"
    }
  }) {
    nodes {
      title
      date
      dateGmt
    }
  }
}

Does this close any currently open issues?

Closes #1234

Any other comments?

WPGRAPHQL RULZ!

Where has this been tested?

Operating System: macOS 10.15.3
WordPress Version: 5.4

…r fields so that strtotime()-compatible strings can be passed in
@netlify
Copy link

netlify bot commented Apr 14, 2020

Deploy request for wpgraphql-docs accepted.

Accepted with commit e692197

https://app.netlify.com/sites/wpgraphql-docs/deploys/5e96105748903f00071b829c

@codecov
Copy link

codecov bot commented Apr 14, 2020

Codecov Report

Merging #1239 into develop will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1239      +/-   ##
===========================================
+ Coverage    63.78%   63.79%   +0.01%     
===========================================
  Files          165      164       -1     
  Lines         9529     9510      -19     
===========================================
- Hits          6078     6067      -11     
+ Misses        3451     3443       -8     
Impacted Files Coverage Δ
src/Registry/TypeRegistry.php 81.41% <ø> (-0.04%) ⬇️
src/Type/Input/DateQueryInput.php 51.72% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3fa876...e692197. Read the comment docs.

@jasonbahl
Copy link
Collaborator

jasonbahl commented Apr 14, 2020

@kellenmace thanks for the PR. I'll try and review shortly and provide my thoughts. 🙏

Copy link
Member

@CodeProKid CodeProKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kellenmace I left some of my high level thoughts on here.

@@ -38,12 +38,12 @@ public static function register_type() {
'description' => __( 'Second (0 to 59)', 'wp-graphql' ),
],
'after' => [
'type' => 'DateInput',
'description' => __( 'Nodes should be returned after this date', 'wp-graphql' ),
'type' => 'String',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need tighter validation here. I think it would be better to introduce a new DateTime scalar: https://webonyx.github.io/graphql-php/type-system/scalar-types/#writing-custom-scalar-types and use that here instead.

namespace WPGraphQL\Type\Input;

class DateInput {
public static function register_type() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is probably a pretty widely used input arg, I'd rather see us deprecate the existing field and introduce the new field separately. We could then make the breaking change in a future release.

@jasonbahl
Copy link
Collaborator

@kellenmace I've added register_graphql_scalar() as an API and I think we should probably have a maintainers meeting sooner than later to discuss what scalars might make sense to introduce and how we should introduce them. If we go the route of adding a DATETIME scalar, it would be perfect for this.

@stale
Copy link

stale bot commented Aug 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2022
@humet
Copy link

humet commented Aug 15, 2022

This would be very useful for us.

@stale stale bot removed the stale label Aug 15, 2022
@rgevrek
Copy link

rgevrek commented Sep 2, 2022

This is a very useful PR, are there any plans to finish and merge? Else many inefficient calls and responses are needed on our side

@justlevine justlevine added the Compat: Breaking Change This is a breaking change to existing functionality label Sep 24, 2022
@stale
Copy link

stale bot commented Dec 24, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale? May need to be revalidated due to prolonged inactivity label Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat: Breaking Change This is a breaking change to existing functionality Stale? May need to be revalidated due to prolonged inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to query for posts before or after a specific time (not just date)
6 participants