Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

timward60
Copy link
Contributor

Support null query when running APQ request. This is upstream merge of our commit made by @joshjcarrier

#4008

This pull request modifies the ExecutionInput logic to return a persisted query marker when a null or empty query is provided along with a persistedQuery extension, ensuring graceful handling of APQ requests.

  • src/main/java/graphql/ExecutionInput.java: Introduces a new static method (assertQuery) to check for null/empty queries and returns a persisted query marker if appropriate; also removes the strict non-null assertion in the builder.
  • src/test/groovy/graphql/ExecutionInputTest.groovy: Adds a test case validating that a null query with the persistedQuery extension returns the expected persisted query marker.

…g APQ request

Support null query when running APQ request

Full issue described in graphql-java#4008

----
#### AI description  (iteration 1)
#### PR Classification
Bug fix: Enhance ExecutionInput to properly handle null queries in automatic persisted query (APQ) requests.

#### PR Summary
This pull request modifies the ExecutionInput logic to return a persisted query marker when a null or empty query is provided along with a persistedQuery extension, ensuring graceful handling of APQ requests.
- `src/main/java/graphql/ExecutionInput.java`: Introduces a new static method (`assertQuery`) to check for null/empty queries and returns a persisted query marker if appropriate; also removes the strict non-null assertion in the builder.
- `src/test/groovy/graphql/ExecutionInputTest.groovy`: Adds a test case validating that a null query with the persistedQuery extension returns the expected persisted query marker.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->

Related work items: #355548

# Conflicts:
#	src/test/groovy/graphql/ExecutionInputTest.groovy
@dondonz
Copy link
Member

dondonz commented Jul 13, 2025

Hello wanted to say, thanks so much for yet another PR! Thanks for all your time and effort

Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

Lets decide on the API shape - specific method or extension entry ??

def "uses persisted query marker when query is empty and extensions contains persistedQuery"() {
when:
def executionInput = ExecutionInput.newExecutionInput()
.extensions([persistedQuery: "any"])
Copy link
Member

Choose a reason for hiding this comment

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

So the question then is

should we provide a helper builder method (that sets the query for you to the magic value) or use a "map entry" in extentions.

I feel like the former is better but would love to why you chose "extensions" - was there a client reason ?

@bbakerman
Copy link
Member

Lets decide on the API shape - specific method or extension entry ??

Lets not do this in this PQ as suggested - I misundertood the problem being solved

Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

I approve but I would love to see the constant and comment suggestion actioned

def "uses persisted query marker when query is empty and extensions contains persistedQuery"() {
when:
def executionInput = ExecutionInput.newExecutionInput()
.extensions([persistedQuery: "any"])
Copy link
Member

Choose a reason for hiding this comment

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

And hence to this code - leave it as it is

@timward60
Copy link
Contributor Author

I approve but I would love to see the constant and comment suggestion actioned

Applied suggestions.

private static boolean isPersistedQuery(Builder builder) {
return builder.extensions != null &&
builder.extensions.containsKey(APOLLO_AUTOMATIC_PERSISTED_QUERY_EXTENSION);
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice code

@bbakerman bbakerman added this to the 25.x breaking changes milestone Jul 21, 2025
@bbakerman bbakerman merged commit 43a54fc into graphql-java:master Jul 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants