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

Federation: unnecessary query #340

Open
1 of 6 tasks
paneq opened this issue Nov 11, 2019 · 0 comments
Open
1 of 6 tasks

Federation: unnecessary query #340

paneq opened this issue Nov 11, 2019 · 0 comments

Comments

@paneq
Copy link

paneq commented Nov 11, 2019

Let's say you have me query which returns type User defined in Accounts service. The current user can have some reviews which are served from Reviews service.

Let's say current user ID is known based on JWT token in an Authorization header.

When asking for:

me {
  reviews
}

the GQL gateway queries accounts service even though the client does not ask for any attributes from it. This seems unnecessary.

QueryPlan {
  Sequence {
    Fetch(service: "accounts") {
      {
        me {
          __typename
        }
      }
    },
    Flatten(path: "me") {
      Fetch(service: "reviews") {
        {
          ... on User {
            __typename
          }
        } =>
        {
          ... on User {
            reviews {
              body
            }
          }
        }
      },
    },
  },
}

The expected behavior would be that only a single query to Reviews service is sent and no query gets sent to the Accounts service.

Checklist for myself

  • A short, but descriptive title. The title doesn't need "Apollo" in it.
  • The package name and version of Apollo showing the problem.
  • If applicable, the last version of Apollo where the problem did not occur.
  • The expected behavior.
  • The actual behavior.
  • A simple, runnable reproduction!
    Please make a GitHub repository that anyone can clone and run and see the
    problem. Other great ways to demonstrate a reproduction are using our
    CodeSandbox template (https://codesandbox.io/s/apollo-server), or re-mixing
    our Glitch template (https://glitch.com/~apollo-launchpad).
@abernix abernix transferred this issue from apollographql/apollo-server Jan 15, 2021
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

1 participant