Skip to content

Commit

Permalink
Merge pull request #191 from Jimexist/feature/code-cleanup
Browse files Browse the repository at this point in the history
some code cleanup
  • Loading branch information
markphilpot committed Aug 23, 2016
2 parents 0ad210c + 9defb69 commit e02f63f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/graphql/relay/Base64.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package graphql.relay;

import java.nio.charset.Charset;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;


public class Base64 {

private Base64() {
}

public static String toBase64(String string) {
try {
return DatatypeConverter.printBase64Binary(string.getBytes("utf-8"));
Expand All @@ -15,6 +19,6 @@ public static String toBase64(String string) {
}

public static String fromBase64(String string) {
return new String(DatatypeConverter.parseBase64Binary(string));
return new String(DatatypeConverter.parseBase64Binary(string), Charset.forName("UTF-8"));
}
}
18 changes: 18 additions & 0 deletions src/main/java/graphql/relay/Relay.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public GraphQLInterfaceType nodeInterface(TypeResolver typeResolver) {
.typeResolver(typeResolver)
.field(newFieldDefinition()
.name("id")
.description("The ID of an object")
.type(new GraphQLNonNull(GraphQLID))
.build())
.build();
Expand Down Expand Up @@ -192,13 +193,30 @@ public GraphQLFieldDefinition mutationWithClientMutationId(String name, String f
}

public static class ResolvedGlobalId {

public ResolvedGlobalId(String type, String id) {
this.type = type;
this.id = id;
}

/**
* @deprecated use {@link #getType()}
*/
@Deprecated
public String type;
/**
* @deprecated use {@link #getId()}
*/
@Deprecated
public String id;

public String getType() {
return type;
}

public String getId() {
return id;
}
}

public String toGlobalId(String type, String id) {
Expand Down

0 comments on commit e02f63f

Please sign in to comment.