{"action":"created","issue":{"url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/11","repository_url":"https://api.github.com/repos/graphql-java/graphql-java-annotations","labels_url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/11/comments","events_url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/11/events","html_url":"https://github.com/graphql-java/graphql-java-annotations/issues/11","id":156356425,"number":11,"title":"Execution of the object doesn't run the method","user":{"login":"hyeluri","id":3065304,"avatar_url":"https://avatars.githubusercontent.com/u/3065304?v=3","gravatar_id":"","url":"https://api.github.com/users/hyeluri","html_url":"https://github.com/hyeluri","followers_url":"https://api.github.com/users/hyeluri/followers","following_url":"https://api.github.com/users/hyeluri/following{/other_user}","gists_url":"https://api.github.com/users/hyeluri/gists{/gist_id}","starred_url":"https://api.github.com/users/hyeluri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyeluri/subscriptions","organizations_url":"https://api.github.com/users/hyeluri/orgs","repos_url":"https://api.github.com/users/hyeluri/repos","events_url":"https://api.github.com/users/hyeluri/events{/privacy}","received_events_url":"https://api.github.com/users/hyeluri/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-23T20:12:09Z","updated_at":"2016-05-24T04:42:05Z","closed_at":"2016-05-24T03:12:49Z","body":"I'm trying to port over some code written in vanilla graphql-java to start using annotations.\r\n\r\nI've got code that looks like this:\r\n\r\n```java\r\n    @GraphQLName(\"VersionType\")\r\n    @GraphQLDescription(\"VersionType\")\r\n    private static class Version {\r\n        @GraphQLField\r\n        public @NotNull String version() {\r\n            return \"1.0.0\";\r\n        }\r\n    }\r\n\r\n    @SneakyThrows\r\n    private static GraphQLObjectType getVersionType() {\r\n        return GraphQLAnnotations.object(Version.class);\r\n    }\r\n\r\n    private static GraphQLObjectType queryType = newObject()\r\n        .name(\"Query\")\r\n        .field(newFieldDefinition()\r\n            .name(\"Version\")\r\n            .type(GraphQLString)\r\n            .staticValue(\"1.0.0\")\r\n            .build()\r\n        )\r\n        ...\r\n        .build()\r\n\r\n\r\n    protected static GraphQLSchema schema = newSchema()\r\n        .query(queryType)\r\n        .mutation(mutationType)\r\n        .build();\r\n\r\n    public static GraphQL graphQL = new GraphQL(schema);\r\n```\r\n\r\nNow, the object builds correctly and the schema for the object type shows up. But when I try to do any query, I always get null back. The `String version()` method isn't even called.\r\n\r\nI'm using the latest version of GraphQL-java (2.0.0) and everything is working fine in the other parts of the scheme written without annotations.\r\n\r\nThanks for the help in advance."},"comment":{"url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/comments/221165023","html_url":"https://github.com/graphql-java/graphql-java-annotations/issues/11#issuecomment-221165023","issue_url":"https://api.github.com/repos/graphql-java/graphql-java-annotations/issues/11","id":221165023,"user":{"login":"nmn","id":3582514,"avatar_url":"https://avatars.githubusercontent.com/u/3582514?v=3","gravatar_id":"","url":"https://api.github.com/users/nmn","html_url":"https://github.com/nmn","followers_url":"https://api.github.com/users/nmn/followers","following_url":"https://api.github.com/users/nmn/following{/other_user}","gists_url":"https://api.github.com/users/nmn/gists{/gist_id}","starred_url":"https://api.github.com/users/nmn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmn/subscriptions","organizations_url":"https://api.github.com/users/nmn/orgs","repos_url":"https://api.github.com/users/nmn/repos","events_url":"https://api.github.com/users/nmn/events{/privacy}","received_events_url":"https://api.github.com/users/nmn/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T04:42:05Z","updated_at":"2016-05-24T04:42:05Z","body":"```java\r\n @GraphQLName(\"VersionType\")\r\n    @GraphQLDescription(\"VersionType\")\r\n    private static class Version {\r\n        @GraphQLField\r\n        public @NotNull String version() {\r\n            return \"1.0.0\";\r\n        }\r\n    }\r\n\r\n    @SneakyThrows\r\n    private static GraphQLObjectType getVersionType() {\r\n        return GraphQLAnnotations.object(Version.class);\r\n    }\r\n\r\n    private static GraphQLObjectType queryType = newObject()\r\n        .name(\"Query\")\r\n        .field(newFieldDefinition()\r\n            .name(\"version\")\r\n            .type(getVersionType())\r\n            .build()\r\n        )\r\n        ...\r\n        .build()\r\n\r\n\r\n    protected static GraphQLSchema schema = newSchema()\r\n        .query(queryType)\r\n        .mutation(mutationType)\r\n        .build();\r\n\r\n    public static GraphQL graphQL = new GraphQL(schema);\r\n```\r\n\r\nThat is the code we were trying to use. So we were getting an exception. When the method was being invoked, it was invoked on null or an object that was not of the class 'Version'. We figured that out after going through the code.\r\n\r\nHowever, I  still don't understand how to use annotations to define the QueryType which has no environment.getSource value. If the classes need to match, it'll always be called on Null."}}
{"actor":{"display_login":"nmn"}}