Skip to content
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

use defaultClient in @Apollo Decorator #22

Closed
Quramy opened this issue Jun 3, 2016 · 4 comments
Closed

use defaultClient in @Apollo Decorator #22

Quramy opened this issue Jun 3, 2016 · 4 comments

Comments

@Quramy
Copy link

Quramy commented Jun 3, 2016

Hi. I'm trying angular2-apollo reading http://docs.apollostack.com/apollo-client/angular2.html#apollo .
I'm confused because the following usage of Apollo decorator:

@Component({...})
@Injectable()
@Apollo({
  client,
  queries(context) {...}
})
class postsList {

}

It seems that the client parameter is required. Can you make it optional? I want angular2-apollo uses the defaultApolloClient by the default.

@Urigo
Copy link
Collaborator

Urigo commented Jun 15, 2016

@Quramy how would you want to see the API?
also how would the import statements look?

@Quramy
Copy link
Author

Quramy commented Jun 16, 2016

Thanks for your reply.

I see https://github.com/apollostack/angular2-apollo/blob/master/src/angular2Apollo.ts#L14 so it seems that we can use the apolloClient provided by Angular2Apollo service.

And I also see https://github.com/apollostack/angular2-apollo/blob/master/examples/hello-world/client/main.ts#L35 .
In this code, you set client option to @Apollo decorator's argument but the client isn't provided by the Angular2Apollo provider. Why don't you use the client provided by Angular2Apollo in @Apollo decorator ? Are decorators and providers(DI) incompatible?

@kamilkisiela
Copy link
Owner

We would have to wrap the constructor of a component to have an access to defaultApolloClient. I'm going to think about it!

@kamilkisiela
Copy link
Owner

Closing in favor of #41

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

No branches or pull requests

3 participants