Fix bad introspection result for an endpoint URL string #2894
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR Fixes #2876 where the
printSchemaFromEndpoint
function is assuming the server will serve back JSON regardless of headers.If a user passed a URL for a graphql endpoint to the github action, and headers are a requirement to determine the response (particularly when assuming the response is JSON) then the endpoint will respond with unsupported content type.
This change updates the headers sent as part of the fetch request to request the content-type to be JSON if it hasn't been provided as part of an Endpoint.
Type of change
Please delete options that are not relevant.
expected)
Screenshots/Sandbox (if appropriate/relevant):
Adding links to sandbox or providing screenshots can help us understand more about this PR and take
action on it as appropriate
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can
reproduce. Please also list any relevant details for your test configuration
See: https://github.com/graphql-hive/graphql-inspector/compare/master...ianc-flwls:graphql-inspector:fix-2876-bad-data-response?expand=1#diff-f4ab9ab13ff697781f89b03a3bc415887db2fab4f9181fefd210e7cf4ded1d02
Test Environment:
I ran
pnpm run test
Checklist:
CONTRIBUTING doc and the
style guidelines of this project