Hi,
Using Apollo Federation 2. Using graphql-request for syncronous communication between subgraphs.
In one of my subgraph (food) I’m using codegen to generate graphql types using supergraph;
codegen.ts
import { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: '../router/supergraph-schema.graphql',
documents: ['./src/gql_definitions/queries.ts'],
ignoreNoDocuments: true,
generates: {
'./src/gql/': {
preset: 'client',
plugins: [],
},
},
};
export default config;
My query is;
import { graphql } from '../gql/gql';
export const CITY = graphql(`
query City($cityId: Int!) {
city(id: $cityId) {
id
name
population
}
}
`);
finally, below files created successfully;
./gql/fragment-masking.ts
./gql/gql.ts
./gql/graphql.ts
./gql/index.ts
However, all the super schema entities are generated in graphql.ts
. This causes unnecessary builds of my food microservice just because of some changes which are not related to my food service, it’s using only city query. In a monorepo environment, I’m trying to save the microservices from unnecessary builds.
Is it possible to generate only the needed part of the schema? Or any other suggestion?
I love graphql codegenerator, thank you all for it