hotchoc's AddApolloFederation schema vs non-apollo subgraph

You might be wondering what is the difference if you use 'AddApolloFederation'  besides resolving a bunch of ambiguous static extension in your code? 

One of the biggest difference I noticed is schema generated - as you can see below. Although this is not a apple by apple comparison. there's extra schema definition here:- 

schema
  @link(
    url: "https://specs.apollo.dev/federation/v2.6"
    import: ["@tag", "FieldSet"]
  ) {
  query: Query
}       



As you can see here, we have "query: Query". This can only be one. If you have more than one, we will get into a schema definition error. 

In graphql federation, you will see similar schema definition. Let's say you have a product and user subgraph, it would look something like below. You will notice we extended Query type using extend type Query. So really important to keep this construct or setup. 


// product subgraph

extend type Query {

  products: [Product]

}

// user subgraph 

extend type Query {

  user(id: ID!): User

}





Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type