Skip to content

Add METHOD to the @GraphQLIgnore annotation target #165

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

Conversation

anotender
Copy link
Contributor

@anotender anotender commented Aug 19, 2019

Fixes #153 by adding METHOD to annotation target, so given @GraphQLIgnore annotation

@Target( { TYPE, FIELD, METHOD })
@Retention(RUNTIME)
public @interface GraphQLIgnore {
}

can be applied on getter methods in entity class to exclude these properties from schema mapping, i.e.:

@Data
@Entity
@EqualsAndHashCode(exclude="author")
public class Book {
    @Id
    Long id;

    String title;

    @ManyToOne(fetch=FetchType.LAZY, optional = false)
    Author author;

    @Transient
    @GraphQLIgnore
    public String getAuthorName(){
    	return author.getName();
    }
}

@codecov
Copy link

codecov bot commented Aug 19, 2019

Codecov Report

Merging #165 into master will increase coverage by 0.01%.
The diff coverage is 84.78%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #165      +/-   ##
============================================
+ Coverage     68.11%   68.12%   +0.01%     
- Complexity      498      503       +5     
============================================
  Files            33       33              
  Lines          2578     2576       -2     
  Branches        431      431              
============================================
- Hits           1756     1755       -1     
  Misses          644      644              
+ Partials        178      177       -1
Impacted Files Coverage Δ Complexity Δ
...ures/graphql/jpa/query/schema/model/book/Book.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...phql/jpa/query/schema/impl/IntrospectionUtils.java 84.37% <87.09%> (-0.48%) 7 <7> (+2)
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 89.04% <92.3%> (+0.28%) 126 <8> (+3) ⬆️

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 4bf7596...0ca4982. Read the comment docs.

@igdianov
Copy link
Collaborator

@anotender Thanks for the PR. It would be nice to have a test case for this

@anotender
Copy link
Contributor Author

@igdianov I've just added additional test cases and a couple of code changes required to work correctly. Please have a look if it looks ok ;)

@igdianov
Copy link
Collaborator

@anotender Thanks! I am traveling at the moment. I will review everything over the weekend.

Copy link
Collaborator

@igdianov igdianov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anotender LGTM Thank you very much for contribution.

@igdianov igdianov merged commit 8028d12 into introproventures:master Aug 24, 2019
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.

GraphQLIgnore is checked against Methods but cannot be applied to them
2 participants