Skip to content

feat: Provide default GraphQLObjectCoercing fallback for non-existing Java classes #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented May 5, 2019

This PR adds support for generating Java Scalar type with default GraphQLObjectCoercing fallback for non-registered Java classes in JavaScalars type registry, i.e.

// given
Class<?> clazz = VariableValue.class;

// when
GraphQLScalarType scalarType = JavaScalars.of(clazz);

// then
assertThat(scalarType.getCoercing()).isInstanceOf(GraphQLObjectCoercing.class);
assertThat(scalarType.getName()).isEqualTo("VariableValue");

It is possible to override default by registering custom Java scalar type as follows:

//given
JavaScalars.register(Map.class, new GraphQLScalarType("Map", "Map Object Type", new GraphQLObjectCoercing()));

//when
GraphQLScalarType scalarType = JavaScalars.of(Map.class);
        
//then
Coercing<?,?> coercing = scalarType.getCoercing();

assertThat(coercing).isInstanceOf(GraphQLObjectCoercing.class);
assertThat(scalarType.getName()).isEqualTo("Map");

@igdianov igdianov self-assigned this May 5, 2019
@codecov
Copy link

codecov bot commented May 5, 2019

Codecov Report

Merging #130 into master will decrease coverage by 0.09%.
The diff coverage is 25%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #130     +/-   ##
===========================================
- Coverage     68.18%   68.08%   -0.1%     
  Complexity      400      400             
===========================================
  Files            33       33             
  Lines          2065     2068      +3     
  Branches        307      307             
===========================================
  Hits           1408     1408             
- Misses          532      535      +3     
  Partials        125      125
Impacted Files Coverage Δ Complexity Δ
...ventures/graphql/jpa/query/schema/JavaScalars.java 45.41% <25%> (-0.58%) 4 <1> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f9da5f...7f9002d. Read the comment docs.

@igdianov igdianov changed the title feat: Provide default Object scalar fallback for non-existing Java classes feat: Provide default GraphQLObjectCoercing fallback for non-existing Java classes May 5, 2019
@igdianov igdianov merged commit 1a27eee into master May 5, 2019
@igdianov igdianov deleted the igdianov-default-java-scalar-object branch May 5, 2019 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant