Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Add support for graphql-java-annotations? #5

Closed
exports opened this issue Apr 25, 2017 · 6 comments
Closed

Add support for graphql-java-annotations? #5

exports opened this issue Apr 25, 2017 · 6 comments
Milestone

Comments

@exports
Copy link

exports commented Apr 25, 2017

Currently this project can discover schema automatically defined by graphql-java-tools, it would be good if we can support graphql-java-annotations too.

@apottere
Copy link
Collaborator

Do you happen to have ideas about how this could work? I don't use annotations so I'm not sure if I'm the right person to implement this.

@apottere
Copy link
Collaborator

@bbakerman do you have any input on how this might work?

@mushketyk
Copy link

Hi @exports

I suggest to read discussion in #20. I've described a way to access Spring beans from graphql-annotations data fetchers and @apottere is working on making it possible in graphql-spring-boot.

@seetharamani
Copy link

seetharamani commented Jul 15, 2018

Instead of using graphql-spring-boot
I have used graphql-java-servlet to work along with graphql-java-annotations, as suggested in the issue #20. I am able to start my application and access the graphql schema in the url /graphql/schema.json. But when I try to execute my any query or mutation, I am getting below exception.

Caused by: java.lang.NoSuchFieldException: newAuthor
	at java.lang.Class.getDeclaredField(Class.java:2070) ~[na:1.8.0_162]
	at graphql.annotations.dataFetchers.MethodDataFetcher.getFieldValue(MethodDataFetcher.java:139) ~[graphql-java-annotations-5.3.jar!/:na]
	at graphql.annotations.dataFetchers.MethodDataFetcher.get(MethodDataFetcher.java:61) ~[graphql-java-annotations-5.3.jar!/:na]

Schema itself looks good with my Query type listing newAuthor as a field. But its not resolving from the Query GraphQLObjectType

Below is how I defined my Query


import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import graphql.annotations.annotationTypes.GraphQLField;
import graphql.annotations.annotationTypes.GraphQLName;
import graphql.annotations.annotationTypes.GraphQLNonNull;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
@GraphQLName("query")
public class Query implements GraphQLQueryResolver {

    private final AuthorRepository authorRepository;
    private final BookRepository bookRepository;

    @GraphQLField
    public Iterable<Book> findAllBooks() {
        return bookRepository.findAll();
    }

    @GraphQLField
    public Iterable<Author> findAllAuthors() {
        return authorRepository.findAll();
    }

    @GraphQLField
    public long countBooks() {
        return bookRepository.count();
    }

    @GraphQLField
    public long countAuthors() {
        return authorRepository.count();
    }
}

Here is the screenshot of my generated schema showing the mutation type have newAuthor field.

screen shot 2018-07-15 at 4 55 39 pm

@benneq
Copy link

benneq commented Aug 20, 2018

I guess the problem is, that graphql-java-annotations inspects the class itself, but not the instantiated singleton object.
I created an issue here ( Enigmatis/graphql-java-annotations#187 ), asking to allow inspecting objects, instead of classes only.

BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Apr 18, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Apr 18, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 10, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 10, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 10, 2020
…trate GraphQL Annotations support"

This reverts commit 8ea966e
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 10, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 10, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue May 28, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
…ce is exposed as bean

If no custom implementation is provided.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
…ql-java-tools interfaces

Also remove the dependency on GraphQL Java Tools. Instead of using the
marker interfaces from this library, annotations of the same name are
defined for the same purpose.

Revert Reflections library version because of a critical issue.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
…trate GraphQL Annotations support"

This reverts commit 8ea966e
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
…ce is exposed as bean

If no custom implementation is provided.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 7, 2020
…ql-java-tools interfaces

Also remove the dependency on GraphQL Java Tools. Instead of using the
marker interfaces from this library, annotations of the same name are
defined for the same purpose.

Revert Reflections library version because of a critical issue.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
…trate GraphQL Annotations support"

This reverts commit 8ea966e
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
…ce is exposed as bean

If no custom implementation is provided.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
…ql-java-tools interfaces

Also remove the dependency on GraphQL Java Tools. Instead of using the
marker interfaces from this library, annotations of the same name are
defined for the same purpose.

Revert Reflections library version because of a critical issue.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jun 27, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
…ls configuration

This change is no longer required for GraphQL Annotations integration
to work, as it excludes this dependency.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
…trate GraphQL Annotations support"

This reverts commit 8ea966e
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
…ce is exposed as bean

If no custom implementation is provided.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
…ql-java-tools interfaces

Also remove the dependency on GraphQL Java Tools. Instead of using the
marker interfaces from this library, annotations of the same name are
defined for the same purpose.

Revert Reflections library version because of a critical issue.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
…ls configuration

This change is no longer required for GraphQL Annotations integration
to work, as it excludes this dependency.
BlasiusSecundus added a commit to BlasiusSecundus/graphql-spring-boot that referenced this issue Jul 12, 2020
@oliemansm oliemansm added this to the 7.2.0 milestone Sep 6, 2020
@oliemansm
Copy link
Member

This has been added to 7.2.0 thanks to @BlasiusSecundus

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants