Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.idea
.gradle
build
classes
_site
generated-src/
11 changes: 9 additions & 2 deletions src/main/java/graphql/introspection/Introspection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package graphql.introspection;


import graphql.language.AstValueHelper;
import graphql.language.AstPrinter;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.GraphQLArgument;
Expand All @@ -11,6 +13,7 @@
import graphql.schema.GraphQLFieldsContainer;
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLInterfaceType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLNonNull;
Expand Down Expand Up @@ -98,15 +101,19 @@ public enum TypeKind {
.dataFetcher(environment -> {
if (environment.getSource() instanceof GraphQLArgument) {
GraphQLArgument inputField = environment.getSource();
return inputField.getDefaultValue() != null ? inputField.getDefaultValue().toString() : null;
return inputField.getDefaultValue() != null ? print(inputField.getDefaultValue(), inputField.getType()) : null;
} else if (environment.getSource() instanceof GraphQLInputObjectField) {
GraphQLInputObjectField inputField = environment.getSource();
return inputField.getDefaultValue() != null ? inputField.getDefaultValue().toString() : null;
return inputField.getDefaultValue() != null ? print(inputField.getDefaultValue(), inputField.getType()) : null;
}
return null;
}))
.build();

private static String print(Object value, GraphQLInputType type) {
return AstPrinter.printAst(AstValueHelper.astFromValue(value, type));
}


public static GraphQLObjectType __Field = newObject()
.name("__Field")
Expand Down
Loading