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

Revise JSONPath options in GraphQlTester #278

Closed
jord1e opened this issue Jan 30, 2022 · 5 comments
Closed

Revise JSONPath options in GraphQlTester #278

jord1e opened this issue Jan 30, 2022 · 5 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jord1e
Copy link
Contributor

jord1e commented Jan 30, 2022

The existing methods do not cover this case. The valueIsEmpty and valueIsNotEmpty methods do way more checks.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 30, 2022
@jord1e jord1e changed the title Add GraphQlTester.PathSpec#is(Not)Null() method Add GraphQlTester.PathSpec#is(Not)Null() methods Jan 30, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Feb 8, 2022

I've made a small adjustment in 2095e17.

That aside, you can use pathExists().valueDoesNotExist() if you want to check both that the path is present and there is no value there, or otherwise valueDoesNotExist() if it's enough to check there isn't a value one, and possibly no such path at all.

Apart from trying to keep the combinations down, null is a tricky concept with a JSONPath which can be indefinite.

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Feb 8, 2022
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 15, 2022
@jord1e
Copy link
Contributor Author

jord1e commented Feb 16, 2022

The concepts of absence and null are clearly separated in the spec: https://spec.graphql.org/draft/#sel-FAHlBFDCAACEMnwN

Fields are always optional within the context of a selection set, a field may be omitted and the selection set is still valid. However fields that return Non-Null types will never return the value null if queried.

It talks about "optional" fields (the absence of a field). and Non-Null/Null fields, aka "field is present but null"

These two states should both be assert-able separately

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Feb 16, 2022
@rstoyanchev rstoyanchev self-assigned this Mar 21, 2022
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Mar 21, 2022
@rstoyanchev rstoyanchev added this to the 1.0.0-M6 milestone Mar 21, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Mar 21, 2022

On further thought and review, I'm going to re-purpose this for a broader update of the available options. The current choice is confusing, with some options overlapping, valueExists and valueIsNotEmpty, while overall there are too many options and a lack of guidance.

As far as I can see, the following should suffice:

  • hasValue - valid field, possibly partial but not null
  • isNull - failed field, or optional field set to null
  • doesNotExist - the path is not even present

Note, the isNull check can only apply to single value paths, e.g. books, books[1].title. Indefinite paths like book[*], book[?(@.category = 'fiction')] cannot be supported and will be rejected.

For anything beyond, there is toEntity and toEntityList.

@rstoyanchev rstoyanchev changed the title Add GraphQlTester.PathSpec#is(Not)Null() methods Revise JSONPath options in GraphQlTester Mar 21, 2022
bclozel added a commit to spring-projects/spring-boot that referenced this issue Mar 21, 2022
@jord1e
Copy link
Contributor Author

jord1e commented Mar 22, 2022

Sounds great, exactly what the issue was aimed at, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants