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

Warning that injecting a network layer would overwrite a previously injected layer #1122

Closed
soosap opened this issue May 6, 2016 · 7 comments

Comments

@soosap
Copy link

soosap commented May 6, 2016

Since 0.8.1 I am receiving this new warning >> Warning: RelayNetworkLayer: Call received to injectImplementation(), but a layer was already injected. << when I try to inject my default network layer. I want to separate my GraphQL server from my React/Relay app. I have not injected any other network layer before that. Relay seems to do this by default.

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer(process.env.GRAPHQL_ENDPOINT)
);

What is the right way to go about it to avoid this warning?

@wincent
Copy link
Contributor

wincent commented May 6, 2016

This is fixed and will be resolved in the next release (see #1111). Sorry about the noise, and thanks for the report!

@wincent wincent closed this as completed May 6, 2016
@sedubois
Copy link

@wincent I still see this warning when using Relay.injectNetworkLayer(new Relay.DefaultNetworkLayer(url, options)) with react-relay@0.9.3.

@wincent
Copy link
Contributor

wincent commented Oct 25, 2016

@sedubois: That suggests that a layer was already injected. Would need to see some code to troubleshoot further.

@sedubois
Copy link

sedubois commented Oct 25, 2016

@wincent Yes, a layer was already injected, but I want to update the headers after user authentication. The code is here.

@wincent
Copy link
Contributor

wincent commented Oct 25, 2016

a layer was already injected

Then everything is working as intended. This is why this is a warning and not an error. The purpose is to help people avoid overwriting a layer by mistake (this actually happened at FB, when two separate teams had their own competing layers in a shared context) but still allow people who have a legitimate reason for injecting more than once to do so, albeit with a warning.

If the warning is truly obnoxious to you then we could look at adding a force kind of flag to effectively suppress the warning.

@sedubois
Copy link

sedubois commented Oct 25, 2016

This is why this is a warning and not an error

@wincent It's actually an error (red and still appears when filtering only for Errors in chrome console):

screen shot 2016-10-25 at 18 22 33

If the warning is truly obnoxious to you then we could look at adding a force kind of flag to effectively suppress the warning.

That would be really welcome, yes 😊 I believe the scenario I described is valid and common, and should therefore not pollute the console.

@wincent
Copy link
Contributor

wincent commented Oct 25, 2016

It uses warning (here). Seems like that ends up calling console.error. Feel free to submit a PR.

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