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

The "External Unused" rule lacks complex examples #151

Open
glen-84 opened this issue Jan 28, 2025 · 0 comments
Open

The "External Unused" rule lacks complex examples #151

glen-84 opened this issue Jan 28, 2025 · 0 comments

Comments

@glen-84
Copy link
Contributor

glen-84 commented Jan 28, 2025

There are two examples of @provides usage that are not covered by the spec for the "External Unused" rule:

Example 1

Sub-selections:

type Review {
  id: ID!
  product: Product @provides(fields: "sku variation { size }")
}

type Product @key(fields: "sku variation { id }") {
  sku: String! @external
  variation: ProductVariation!
  name: String!
}

type ProductVariation {
  id: String!
  size: String! @external
}

The spec algorithm fails here, since it expects a @provides directive on a field returning ProductVariation.

Example 2

Fragments:

type Review {
  id: ID!
  # The @provides directive tells us that this source schema can supply different
  # fields depending on which concrete type of Product is returned.
  product: Product
    @provides(
      fields: """
      ... on Book { author }
      ... on Clothing { size }
      """
    )
}

interface Product @key(fields: "id") {
  id: ID!
}

type Book implements Product {
  id: ID!
  title: String!
  author: String! @external
}

type Clothing implements Product {
  id: ID!
  name: String!
  size: String! @external
}

type Query {
  reviews: [Review!]!
}

The spec doesn't include an example like this, which might be useful, even though the algorithm doesn't really define how "references field in @provides" is actually implemented.

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