newrelic / newrelic-node-apollo-server-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spread Fragment Support

YutaUra opened this issue · comments

Is your feature request related to a problem? Please describe.

When you send a request like

fragment UserCard on User {
  name
  image
}
query GetUser {
  user(id: "xxx") {
    ... UserCard
  }
}

, you would expect query/GetUser/user but in fact /undefined/UserCard is actually

Feature Description

A clear and concise description of the feature you want or need.

If the query definition is first and the fragment second, it will work.

# This works
query GetUser {
  user(id: "xxx") {
    ... UserCard
  }
}
fragment UserCard on User {
  name
  image
}

Describe Alternatives

A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to?

In this section, the first item of definitions is retrieved, but it is correct to use responseContext.operation.

const [definition] = responseContext.document.definitions

Additional context

Add any other context here.

Priority

Please help us better understand this feature request by choosing a priority from the following options:
[Nice to Have, Really Want, Must Have, Blocker]

I was going to create a PR to fix this, but I couldn't due to other tests failing and so on.
So I'll paste the work in progress here. I hope this will be helpful to someone else.

main...YutaUra:main

Hi @YutaUra,

Thank you for the request and the code to start approaching a solution! We will take a look and work with PM to get this prioritized (if someone doesn't get to it first).