Skip to content

Commit

Permalink
Add extended message
Browse files Browse the repository at this point in the history
  • Loading branch information
kmccarp committed Nov 5, 2024
1 parent e621be1 commit f6fd939
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 5 deletions.
18 changes: 17 additions & 1 deletion src/main/java/io/moderne/organizations/DgsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ public static class ORGANIZATION_INPUT_ARGUMENT {
}

public static class COMMITMESSAGE_INPUT_ARGUMENT {
public static final String CommitMessage = "commitMessage";
public static final String CommitInput = "commitInput";

public static final String Repository = "repository";
}
}

public static class COMMIT {
public static final String TYPE_NAME = "Commit";

public static final String Message = "message";

public static final String ExtendedMessage = "extendedMessage";
}

public static class ORGANIZATION {
public static final String TYPE_NAME = "Organization";

Expand Down Expand Up @@ -201,6 +209,14 @@ public static class OPTION {
public static final String Value = "value";
}

public static class COMMITINPUT {
public static final String TYPE_NAME = "CommitInput";

public static final String Message = "message";

public static final String ExtendedMessage = "extendedMessage";
}

public static class USER {
public static final String TYPE_NAME = "User";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ Mono<Connection<Organization>> organizationsPages(DataFetchingEnvironment dfe) {
}

@DgsQuery
Mono<String> commitMessage(@InputArgument String commitMessage,
Mono<Commit> commitMessage(@InputArgument CommitInput commitInput,
@InputArgument RepositoryInput repository) {
return Mono.fromCallable(() -> {
// here is where you would put custom logic to reach out to, e.g. JIRA
return commitMessage;
return new Commit(
commitInput.getMessage(),
commitInput.getExtendedMessage()
);
});
}

Expand Down
81 changes: 81 additions & 0 deletions src/main/java/io/moderne/organizations/types/Commit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package io.moderne.organizations.types;

import java.lang.Object;
import java.lang.Override;
import java.lang.String;

public class Commit {
private String message;

private String extendedMessage;

public Commit() {
}

public Commit(String message, String extendedMessage) {
this.message = message;
this.extendedMessage = extendedMessage;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getExtendedMessage() {
return extendedMessage;
}

public void setExtendedMessage(String extendedMessage) {
this.extendedMessage = extendedMessage;
}

@Override
public String toString() {
return "Commit{" + "message='" + message + "'," +"extendedMessage='" + extendedMessage + "'" +"}";
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Commit that = (Commit) o;
return java.util.Objects.equals(message, that.message) &&
java.util.Objects.equals(extendedMessage, that.extendedMessage);
}

@Override
public int hashCode() {
return java.util.Objects.hash(message, extendedMessage);
}

public static io.moderne.organizations.types.Commit.Builder newBuilder() {
return new Builder();
}

public static class Builder {
private String message;

private String extendedMessage;

public Commit build() {
io.moderne.organizations.types.Commit result = new io.moderne.organizations.types.Commit();
result.message = this.message;
result.extendedMessage = this.extendedMessage;
return result;
}

public io.moderne.organizations.types.Commit.Builder message(String message) {
this.message = message;
return this;
}

public io.moderne.organizations.types.Commit.Builder extendedMessage(String extendedMessage) {
this.extendedMessage = extendedMessage;
return this;
}
}
}
82 changes: 82 additions & 0 deletions src/main/java/io/moderne/organizations/types/CommitInput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.moderne.organizations.types;

import java.lang.Object;
import java.lang.Override;
import java.lang.String;

public class CommitInput {
private String message;

private String extendedMessage;

public CommitInput() {
}

public CommitInput(String message, String extendedMessage) {
this.message = message;
this.extendedMessage = extendedMessage;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public String getExtendedMessage() {
return extendedMessage;
}

public void setExtendedMessage(String extendedMessage) {
this.extendedMessage = extendedMessage;
}

@Override
public String toString() {
return "CommitInput{" + "message='" + message + "'," +"extendedMessage='" + extendedMessage + "'" +"}";
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommitInput that = (CommitInput) o;
return java.util.Objects.equals(message, that.message) &&
java.util.Objects.equals(extendedMessage, that.extendedMessage);
}

@Override
public int hashCode() {
return java.util.Objects.hash(message, extendedMessage);
}

public static io.moderne.organizations.types.CommitInput.Builder newBuilder() {
return new Builder();
}

public static class Builder {
private String message;

private String extendedMessage;

public CommitInput build() {
io.moderne.organizations.types.CommitInput result = new io.moderne.organizations.types.CommitInput();
result.message = this.message;
result.extendedMessage = this.extendedMessage;
return result;
}

public io.moderne.organizations.types.CommitInput.Builder message(String message) {
this.message = message;
return this;
}

public io.moderne.organizations.types.CommitInput.Builder extendedMessage(
String extendedMessage) {
this.extendedMessage = extendedMessage;
return this;
}
}
}
14 changes: 12 additions & 2 deletions src/main/resources/schema/organizations.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ type Query {
This is useful for if you need to supply, for example, a ticket number in each commit.
"""
commitMessage(
commitMessage: String!
commitInput: CommitInput!
repository: RepositoryInput!
): String!
): Commit!
}

input CommitInput {
message: String!
extendedMessage: String
}

input User {
Expand All @@ -76,6 +81,11 @@ type Organization {
last: Int): RepositoryConnection!
}

type Commit {
message: String!
extendedMessage: String
}

type OrganizationConnection {
edges: [OrganizationEdge]
pageInfo: PageInfo
Expand Down

0 comments on commit f6fd939

Please sign in to comment.