Skip to content

Add support for generating default URI values#887

Merged
jiholee17 merged 1 commit intomasterfrom
feature/support-default-uri
Oct 27, 2025
Merged

Add support for generating default URI values#887
jiholee17 merged 1 commit intomasterfrom
feature/support-default-uri

Conversation

@jiholee17
Copy link
Copy Markdown
Collaborator

Follow-up to #885 (comment) which removed generating non-compiling string default values for non-string Java types, to add URI support which seems like it would be a common case.

This PR adds explicit support for generating default values for java.net.URI fields using URI.create(). The data type generator validates the URI before generating by wrapping an internal call to URI.create() in a try-catch and errors if the provided URI is invalid. The user must still provide the typeMapping from Uri to java.net.URI.

schema.graphqls:

input Movie {
    uri: Uri = "https://someurl.com"
}

Movie.java:

import java.net.URI;
...
public class MyInput {
    private URI uri = URI.create("https://someurl.com");
    ...

@jiholee17 jiholee17 merged commit c8d65d2 into master Oct 27, 2025
4 checks passed
@jiholee17 jiholee17 deleted the feature/support-default-uri branch October 27, 2025 23:43
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.

4 participants