FDM GraphQL Queries: cast interfaces to their concrete implementation

Related products: Data Modeling

Please add support for missing GraphQL feature ... “spread on types”. This allows generic types to be cast to their concrete implementation when querying the data.

 

Example FDM and Query Below:

type Stall {
  name: String!
  stallNumber: String!
  availableProduce: [Produce]
}
 
interface Produce {
  name: String!
  quantity: Int!
  price: Int!
  nutrients: [String]
  vendor: Stall
  region: String!
}
 
type Fruit implements Produce {
  name: String!
  quantity: Int!
  price: Int!
  nutrients: [String]
  vendor: Stall
  region: String!
  isSeedless: Boolean
  ripenessIndicators: [String]  
}
 
type Vegetable implements Produce {
  name: String!
  quantity: Int!
  price: Int!
  nutrients: [String]
  vendor: Stall
  region: String!
  vegetableFamily: String
  isPickled: Boolean
}

 

query {
  listStall {
    items {
      availableProduce {
        items {
          __typename
          name
          price
          ... on Fruit {
            hasEdibleSeeds
          }
          ... on Vegetable {
            vegetableFamily
          }
        }
      }
    }
  }
}

 

https://cognite.zendesk.com/hc/en-us/requests/9189

https://graphql.com/learn/interfaces-and-unions/#fragments

 

Hi, and thank you for this product idea @tom!

 

We intend to improve our coverage of the GraphQL specification in the Data Modeling GraphQL endpoint, and improved interface support, union support, plus fragments are high on the “should have” list as we work to improve the developer experience. Unfortunately, I do not currently have a set timeframe for when this will be implemented, but as the Product Manager I’m hoping we can deliver something addressing your idea in this the 2nd half of 2023.


Due to limitations in the team capacity, implementing/resolving this product idea has unfortunately been deferred until 2H, 2024. Will place the idea in “Parked” for now, with the goal to re-open and reassess priority at the beginning of Q3, 2024.