{"action":"created","issue":{"url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/33","repository_url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet","labels_url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/33/comments","events_url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/33/events","html_url":"https://github.com/graphql-dotnet/graphql-dotnet/issues/33","id":120130792,"number":33,"title":"Dependency injection?","user":{"login":"tlycken","id":1550920,"avatar_url":"https://avatars.githubusercontent.com/u/1550920?v=3","gravatar_id":"","url":"https://api.github.com/users/tlycken","html_url":"https://github.com/tlycken","followers_url":"https://api.github.com/users/tlycken/followers","following_url":"https://api.github.com/users/tlycken/following{/other_user}","gists_url":"https://api.github.com/users/tlycken/gists{/gist_id}","starred_url":"https://api.github.com/users/tlycken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlycken/subscriptions","organizations_url":"https://api.github.com/users/tlycken/orgs","repos_url":"https://api.github.com/users/tlycken/repos","events_url":"https://api.github.com/users/tlycken/events{/privacy}","received_events_url":"https://api.github.com/users/tlycken/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-12-03T09:52:10Z","updated_at":"2016-02-17T17:52:10Z","closed_at":"2015-12-05T02:53:45Z","body":"I'm really excited that this project exists, and I'm hoping to get an opportunity to make use of it - and thereby also make time to help - at some point. For now, though, I'm just toying around to see where I can get with it :)\r\n\r\nI've noticed a lack of DI in the examples - `var data = new StarwarsData()` is used in a bunch of places. \r\nWhat I'd like to accomplish, is basically to send dependencies (like data stores) as constructor arguments to the various types that need them for resolving things, e.g. \r\n\r\n```\r\n    public class StarWarsQuery : ObjectGraphType\r\n    {\r\n        public StarWarsQuery(IDataReader data)\r\n        {\r\n            Name = \"Query\";\r\n            Field<CharacterInterface>(\"hero\", resolve: context => data.GetDroid(id: 3));\r\n        }\r\n    }\r\n```\r\n\r\nAnd, of course, the `data` parameter here could be just passed-through to wherever it's needed for resolving more stuff.\r\n\r\nAre there any plans for DI support in the future? Perhaps it's already possible, but not shown off in the examples?\r\n"},"comment":{"url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/comments/185324150","html_url":"https://github.com/graphql-dotnet/graphql-dotnet/issues/33#issuecomment-185324150","issue_url":"https://api.github.com/repos/graphql-dotnet/graphql-dotnet/issues/33","id":185324150,"user":{"login":"ManishTrivedi","id":12849757,"avatar_url":"https://avatars.githubusercontent.com/u/12849757?v=3","gravatar_id":"","url":"https://api.github.com/users/ManishTrivedi","html_url":"https://github.com/ManishTrivedi","followers_url":"https://api.github.com/users/ManishTrivedi/followers","following_url":"https://api.github.com/users/ManishTrivedi/following{/other_user}","gists_url":"https://api.github.com/users/ManishTrivedi/gists{/gist_id}","starred_url":"https://api.github.com/users/ManishTrivedi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManishTrivedi/subscriptions","organizations_url":"https://api.github.com/users/ManishTrivedi/orgs","repos_url":"https://api.github.com/users/ManishTrivedi/repos","events_url":"https://api.github.com/users/ManishTrivedi/events{/privacy}","received_events_url":"https://api.github.com/users/ManishTrivedi/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T17:52:10Z","updated_at":"2016-02-17T17:52:10Z","body":"@joemcbride It would be great if you can share your thoughts on these issues:\r\n\r\n1. We register all the types and queries in the GraphQL controller constructor. What if I have 100 types in my system. Will I be registering all in this controller or can I have multiple controllers?\r\n\r\n2. Should I be using Factory method pattern to decide which schema should be used based on the metadata.\r\n\r\n3. Can you please elaborate on what do you mean by top level object in the above comment. If I have StarWarsData.cs and many other data classes, my StarWarsQuery constructor would look like this StarWarsQuery(StarWarsData data, .............. ). I am confused about the dependency injection in the Query class.\r\n\r\nPlease help!"}}