-
Notifications
You must be signed in to change notification settings - Fork 320
Testing Subscriptions using Websocket Client not working #895
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
Comments
I have figured out that whatever annotations are processed with This is all that my test class uses:
For a client to work, it would need the handler registration at the least. Why is there no autoconfiguration happening for the WebSocketConfiguration? Is there something manual I can do to force configuration? |
I found my problem after spending a whole day on it. Turns out its directly related to #308 because the main I think it would be much appreciated it if you could fix that by having it check |
I'm sorry you spent so much time finding the cause here. I don't think we'll change the behavior for #308 as this was solved with #338 - we've separated the default locations for the schema file and the query files. If we were to mix both, you could run into situations where the schema is different in your tests than in production (by having an additional schema file in your test resources). Worse, your application could pick up a schema file that's mistakenly contributed by one of your dependencies. If you're running into similar problem in the future, I would suggest first looking at the startup logs as you should see GraphQL related statements:
If this is not the case, you can add
In your case, you should have seen that no schema was found in the detected location. |
@bclozel I appreciate your response. However you should understand that the error that I was originally getting was a red herring which led me down the wrong path thinking it was something else to do with Spring Security configuration. I did have Because I was not having any issue running the application regularly, there was no reason to believe that the schema was a problem. In other graphql implementations, if no schema is found, they would throw an error no matter if for tests or for production. The user shouldn't have to dig into debug logs to realize that a critical requirement is missing. I would encourage you to rethink your strategy in surfacing such issues. Lastly, why is there no documentation on #338 that describes the default configuration for |
@sgrannan thanks for the feedback. It's still not clear to me what was the intent behind adding a graphql folder in your test resources. Can you elaborate? |
You mean something like this? |
We could do this, but this would prevent anyone from using the GraphQL client in an application that only consumes an external API. If the application itself doesn't provide a schema, we would fail in all cases. Thoughts?
I agree, configuring debug logs on graphql-java is not an effective strategy for understanding setup issues. What about the auto-configuration report as described above? Wouldn't this help in this case? |
The |
I try not to pollute the To give you some background, I am coming as a conversion from |
I think it's a typo, it should be
That's just a shortcut - you can load the document however you want and provide it with the |
Uh oh!
There was an error while loading. Please reload this page.
What is the proper way to test subscriptions using the
WebSocketGraphqlTester
client? Do you have documentation/samples that actually show a full test with the WebSocketGraphqlTester implementation?I could not seem to find any examples that fit my needs in the repos. I believe I need to test with a test client because I have custom Filter and custom Interceptors that have logic for handling authentication and logging of requests. I would like to ensure they are executed within each test.
I have followed the documentation (here) that seems to be based on a
ReactorNettyWebSocketClient
to try to get this tested so far, but I am unable to get it to work because I receive errors. Here is the client setup in my test:Here are my Spring Boot dependencies:
And Test Dependencies:
However, I get a 403 error: org.springframework.graphql.client.GraphQlTransportException: GraphQlTransport error: Invalid handshake response getStatus: 403
With this stack trace:
I should point out that I was required to use the
Webflux
dependency in test to get the WebsocketGraphqlTester properly configured. I believe this may be a source of the issue as some security configuration has been autoconfigured now? My project is more Web MVC like, even with Subscriptions implementation. Note: This is a conversion fromspring-boot-graphql-kickstarter
.Can you point me in the right direction that fits my needs or does Spring GraphQL not support this kind of testing yet?
The text was updated successfully, but these errors were encountered: