-
Imagine I have following query: import { gql } from 'graphql-tag';
export const CarsCompaniesWithRankQuery = gql`
query CarsCompaniesWithRank($cwrInput: RentalCarsCompaniesWithRankInput!) {
cars {
companiesWithRank(input: $cwrInput) {
id
name
logoUrl
cc1
}
}
}
`; and I have following overwrite: true
schema: "./schema.graphql"
documents: "./src/**/*.{ts,tsx,js,jsx,graphql,gql}"
generates:
src/types.ts:
plugins:
- "typescript"
- "typescript-operations" In this scenario I would get following types generated by export type CarsQueries = {
__typename?: 'CarsQueries';
recommendedPickupLocations: Array<Maybe<RentalCarsPickupLocation>>;
companiesWithRank: Array<Maybe<RentalCarsCompanyWithRank>>;
};
export type RentalCarsCompanyWithRank = {
__typename?: 'RentalCarsCompanyWithRank';
id?: Maybe<Scalars['Int']>;
name?: Maybe<Scalars['String']>;
logoUrl?: Maybe<Scalars['String']>;
cc1?: Maybe<Scalars['String']>;
}; Then export type CarsCompaniesWithRankQuery = {
__typename?: 'Query',
cars: {
__typename?: 'CarsQueries',
companiesWithRank: Array<Maybe<{
__typename?: 'RentalCarsCompanyWithRank',
id?: Maybe<number>,
name?: Maybe<string>,
logoUrl?: Maybe<string>,
cc1?: Maybe<string>
}>>
}
}; Basically it's repeating the type definition for export type CarsCompaniesWithRankQuery = {
__typename?: 'Query',
cars: {
__typename?: 'CarsQueries',
companiesWithRank: Array<Maybe<RentalCarsCompanyWithRank>>
}
}; Am I missing anything? Or it's expected situation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
typescript-operations
picks the fields you selected in the operations so it is not alwayscompaniesWithRank: Array<Maybe<RentalCarsCompanyWithRank>>
. If you want to see how it picks it up, you can addpreResolveTypes: false
.