From c7053ac0c7f321a69985b06b966985203afdeaf3 Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Wed, 23 Sep 2020 10:29:01 +0200 Subject: [PATCH] Add GQL fragments --- codegen.yml | 4 +- src/app/graphqlOperations/bike.graphql | 5 + src/app/graphqlOperations/bikes.graphql | 37 +---- .../fragments/bikeFragment.graphql | 38 +++++ src/generated/graphql.ts | 156 ++++++++++++------ 5 files changed, 148 insertions(+), 92 deletions(-) create mode 100644 src/app/graphqlOperations/bike.graphql create mode 100644 src/app/graphqlOperations/fragments/bikeFragment.graphql diff --git a/codegen.yml b/codegen.yml index af765d2..462ea0a 100644 --- a/codegen.yml +++ b/codegen.yml @@ -1,13 +1,15 @@ overwrite: true wtach: true schema: "http://localhost:4000/graphql" -documents: "src/app/graphqlOperations/*" +documents: "src/app/graphqlOperations/**/*" generates: src/generated/graphql.ts: plugins: - "typescript" - "typescript-operations" - "typescript-apollo-angular" + config: + immutableTypes: false ./graphql.schema.json: plugins: - "introspection" diff --git a/src/app/graphqlOperations/bike.graphql b/src/app/graphqlOperations/bike.graphql new file mode 100644 index 0000000..f7f60e0 --- /dev/null +++ b/src/app/graphqlOperations/bike.graphql @@ -0,0 +1,5 @@ +query GetCargoBikeById($id: ID!){ + cargoBikeById(id: $id) { + ...CargoBikeFragment + } +} diff --git a/src/app/graphqlOperations/bikes.graphql b/src/app/graphqlOperations/bikes.graphql index bcfc6fb..76d4761 100644 --- a/src/app/graphqlOperations/bikes.graphql +++ b/src/app/graphqlOperations/bikes.graphql @@ -1,40 +1,5 @@ query GetCargoBikes{ cargoBikes { - id - group - name - events { - date - } - insuranceData { - billing - } - dimensionsAndLoad { - bikeLength - bikeWeight - } - numberOfChildren - security { - frameNumber - adfcCoding - keyNumberAXAChain - keyNumberFrameLock - policeCoding - } - dimensionsAndLoad { - bikeHeight - bikeLength - bikeWeight - bikeWidth - boxHeight - boxLength - boxWidth - hasCoverBox - lockable - maxWeightBox - maxWeightLuggageRack - maxWeightTotal - } - + ...CargoBikeFragment } } diff --git a/src/app/graphqlOperations/fragments/bikeFragment.graphql b/src/app/graphqlOperations/fragments/bikeFragment.graphql new file mode 100644 index 0000000..c4f0cdf --- /dev/null +++ b/src/app/graphqlOperations/fragments/bikeFragment.graphql @@ -0,0 +1,38 @@ +fragment CargoBikeFragment on CargoBike { + id + group + name + events { + date + } + insuranceData { + billing + } + dimensionsAndLoad { + bikeLength + bikeWeight + } + numberOfChildren + security { + frameNumber + adfcCoding + keyNumberAXAChain + keyNumberFrameLock + policeCoding + } + dimensionsAndLoad { + bikeHeight + bikeLength + bikeWeight + bikeWidth + boxHeight + boxLength + boxWidth + hasCoverBox + lockable + maxWeightBox + maxWeightLuggageRack + maxWeightTotal + } +} + diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts index 1323ed6..974b46f 100644 --- a/src/generated/graphql.ts +++ b/src/generated/graphql.ts @@ -657,6 +657,19 @@ export enum CacheControlScope { } +export type GetCargoBikeByIdQueryVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type GetCargoBikeByIdQuery = ( + { __typename?: 'Query' } + & { cargoBikeById?: Maybe<( + { __typename?: 'CargoBike' } + & CargoBikeFragmentFragment + )> } +); + export type GetCargoBikesQueryVariables = Exact<{ [key: string]: never; }>; @@ -664,69 +677,102 @@ export type GetCargoBikesQuery = ( { __typename?: 'Query' } & { cargoBikes: Array - & { events?: Maybe - )>>>, insuranceData: ( - { __typename?: 'InsuranceData' } - & Pick - ), dimensionsAndLoad: ( - { __typename?: 'DimensionsAndLoad' } - & Pick - ), security: ( - { __typename?: 'Security' } - & Pick - ) } + & CargoBikeFragmentFragment )>> } ); +export type CargoBikeFragmentFragment = ( + { __typename?: 'CargoBike' } + & Pick + & { events?: Maybe + )>>>, insuranceData: ( + { __typename?: 'InsuranceData' } + & Pick + ), dimensionsAndLoad: ( + { __typename?: 'DimensionsAndLoad' } + & Pick + ), security: ( + { __typename?: 'Security' } + & Pick + ) } +); + +export const CargoBikeFragmentFragmentDoc = gql` + fragment CargoBikeFragment on CargoBike { + id + group + name + events { + date + } + insuranceData { + billing + } + dimensionsAndLoad { + bikeLength + bikeWeight + bikeHeight + bikeWidth + boxHeight + boxLength + boxWidth + hasCoverBox + lockable + maxWeightBox + maxWeightLuggageRack + maxWeightTotal + } + numberOfChildren + security { + frameNumber + adfcCoding + keyNumberAXAChain + keyNumberFrameLock + policeCoding + } + dimensionsAndLoad { + bikeHeight + bikeLength + bikeWeight + bikeWidth + boxHeight + boxLength + boxWidth + hasCoverBox + lockable + maxWeightBox + maxWeightLuggageRack + maxWeightTotal + } +} + `; +export const GetCargoBikeByIdDocument = gql` + query GetCargoBikeById($id: ID!) { + cargoBikeById(id: $id) { + ...CargoBikeFragment + } +} + ${CargoBikeFragmentFragmentDoc}`; + + @Injectable({ + providedIn: 'root' + }) + export class GetCargoBikeByIdGQL extends Apollo.Query { + document = GetCargoBikeByIdDocument; + + constructor(apollo: Apollo.Apollo) { + super(apollo); + } + } export const GetCargoBikesDocument = gql` query GetCargoBikes { cargoBikes { - id - name - events { - date - } - insuranceData { - billing - } - dimensionsAndLoad { - bikeLength - bikeWeight - bikeHeight - bikeWidth - boxHeight - boxLength - boxWidth - hasCoverBox - lockable - maxWeightBox - maxWeightLuggageRack - maxWeightTotal - } - numberOfChildren - security { - frameNumber - } - dimensionsAndLoad { - bikeHeight - bikeLength - bikeWeight - bikeWidth - boxHeight - boxLength - boxWidth - hasCoverBox - lockable - maxWeightBox - maxWeightLuggageRack - maxWeightTotal - } + ...CargoBikeFragment } } - `; + ${CargoBikeFragmentFragmentDoc}`; @Injectable({ providedIn: 'root'