ghostdogpr / caliban

Functional GraphQL library for Scala

Home Page:https://ghostdogpr.github.io/caliban/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support a way to hide fields from interfaces

paulpdaniels opened this issue · comments

At the moment if you declare a field in a type and then compose it under an interface the interface will automatically expose all of the fields that appear in all implementations of the interface. There are however cases where this is not desirable behavior. Consider for instance a federated graph where different subgraphs expose different implementations of the interface:

// Search graph
interface Product {
  id: ID!
}

type Query {
  search(): [Product!]!
}


// Store graph
type PhysicalProduct implements Product {
   id: ID!
   location: String!
   shippingCost: Int!
}

// Web graph
type WebProduct {
  id: ID!
  url: String!
}

Since each subgraph would not know about the implementations within the other graphs it would have no way of knowing which fields can be safely exposed.

I know magnolia doesn't support resolution of the fields within a scala interface, but we can probably go the other way and exclude them from an interface (perhaps even a specific interface?) by using an annotation like GQLExcludeInterface to mark a field as not visible to the interface.

I can give this a go. I think it should be fairly straightforward with annotations