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

Inputs that expect an ID, should all be of the ID Type and should accept the Integer or Relay ID #109

Open
jasonbahl opened this issue Mar 21, 2017 · 5 comments

Comments

Projects
3 participants
@jasonbahl
Copy link
Collaborator

commented Mar 21, 2017

In various Input args, we're currently setup to accept the WordPress ID as the input, but we should be accepting Global Relay IDs.

For example, the where args for the posts query has an input of authorIn which accepts a list of Ints. . .this should accept a list of IDs and should parse out the WP ID from the Global ID.

Same goes for basically all inputs where the expected input is an ID

More examples, but not necessarily a comprehensive list

authorIn
authorNotIn
categoryAnd
categoryIn
in
notIn
parentIn
parentNotIn
tagAnd
tagIn
tagNotIn

@jasonbahl jasonbahl added the Bug label Mar 21, 2017

@jasonbahl jasonbahl added this to the Stable milestone Mar 21, 2017

@jasonbahl jasonbahl modified the milestones: 1.0 release, Stable Jul 26, 2017

@jasonbahl jasonbahl self-assigned this Oct 10, 2017

@CodeProKid

This comment has been minimized.

Copy link
Member

commented Oct 19, 2017

I will try to come up with a comprehensive list in #221

@jasonbahl jasonbahl added this to To do in Roadmap Mar 20, 2018

@jasonbahl

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 4, 2018

related to #532

@hsimah

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2019

I don't think we should necessarily stop accepting the database IDs as arguments. There are a lot of plugins out there which rely on linking to posts by their ID. For example I integrate with MB Relationships and FacetWP. I personally don't like the idea of using atob in my client to modify an ID returned from the server to request an item.

I do think that there is scope for both input types. Perhaps we could come up with a naming standard where id is the relay ID and databaseId (or similar) is the int value. It would mean duplicated fields, but would ensure flexibility for the end user.

@jasonbahl

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 9, 2019

@hsimah ya, I believe that if the Input type is ID that it can accept either an integer or a String, so we can have the same input field accept either the database ID or the Relay ID

Then let the execution handle what to do.

Like, during execution, as we handle the input we can check something like the following (pseudo code):

if ( is_int( $arg['inputId'] ) {
  $id = absint( $arg['inputId'] );
} else if ( is_relay_id( $args['inputId'] ) {
  $id = Relay::fromGlobalId()['id'];
} else {
  throw new UserError( 'The ID is invalid. . .' );
}

@CodeProKid CodeProKid modified the milestones: 1.0 release, 0.2.2 Jan 15, 2019

@jasonbahl

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 23, 2019

related: #532 and #263

@CodeProKid CodeProKid removed this from the 0.2.2 milestone Jan 29, 2019

@jasonbahl jasonbahl changed the title Inputs should accept Global ID instead of WP IDs Inputs that expect an ID, should all be of the ID Type and should accept the Integer or Relay ID Feb 7, 2019

@CodeProKid CodeProKid added this to the Next Up milestone Jul 10, 2019

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