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

Set Accept header when fetching remote source #2947

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MightyPixel
Copy link

@MightyPixel MightyPixel commented Feb 29, 2024

Hi :)

What?
Explicitly set default Accept header to application/graphql-response+json or application/json.

Why?

  1. The current code breaks if the subgraph responds with text (containing JSON)
    • This was the case when I tried adding a basic Quarkus subgraph (it uses smallrye-graphql internally).
    • It returns the following error:
      • Error: Couldn't load service definitions for "subgraph-poc" at http://localhost:8080/graphql: Expected JSON response body, but received: {"data":{"_service":{"sdl":"schema {\n query: Query\n...
  2. This change also seems consistent with the draft spec of graphql

A valid workaround seems to be:

    supergraphSdl: new IntrospectAndCompose({
      subgraphs: [
      ...
      ],
      introspectionHeaders: {
        Accept: 'application/json',
      }
   })

Considerations

  • Sorry if I've I'm missing anything!
  • I didn't write tests since most of the RemoteGraphQLDataSource methods are private.

@MightyPixel MightyPixel requested a review from a team as a code owner February 29, 2024 16:48
@apollo-cla
Copy link

@MightyPixel: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link

netlify bot commented Feb 29, 2024

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 47a6204

Copy link

changeset-bot bot commented Feb 29, 2024

⚠️ No Changeset found

Latest commit: 47a6204

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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

Successfully merging this pull request may close these issues.

2 participants