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

Documentation is unclear where factory providers arguments are coming from #1995

Open
cowboyd opened this issue Dec 8, 2021 · 4 comments
Open
Labels

Comments

@cowboyd
Copy link

cowboyd commented Dec 8, 2021

Describe the bug
In this doc https://github.com/Urigo/graphql-modules/blob/master/website/docs/di/providers.md#factory

The factory has a dependency Config which is used as a value, but then also used as a type in the argument of the factory. It's not clear what the value or the type is from the code examples. The prose explaining the code example do not explain what these values and types are.

Expected behavior

It should be clear what the values and types represent and where they are coming from.

Environment:

website

@ardatan
Copy link
Collaborator

ardatan commented Dec 8, 2021

It actually comes from deps;

  useFactory(config: Config) {
    if (config.environment === 'production') {
      return 'my-api-key';
    }

    return null;
  },
  deps: [Config] // <<Here

Would you create a PR on the documentation to make it clear?

@ardatan ardatan added the docs label Dec 8, 2021
@cowboyd
Copy link
Author

cowboyd commented Dec 9, 2021

@ardatan where does the value Config in the expression [Config] come from?

@ardatan
Copy link
Collaborator

ardatan commented Dec 9, 2021

It is the injection token, class itself or custom injection token defined in providers
https://github.com/Urigo/graphql-modules/blob/master/website/docs/di/providers.md#defining-tokens

@cowboyd
Copy link
Author

cowboyd commented Dec 13, 2021

I see. It would probably benefit from having an import statement to define the reference to the value in the docs.

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

No branches or pull requests

2 participants