From 1a4b67663523e25c1f18df7e463d8376bbccfd4e Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 30 Sep 2024 17:08:11 -0600 Subject: [PATCH 1/2] Create shot fragment --- src/index.tsx | 128 +++++++++++++++++++++++++++------------ src/operations/shots.gql | 80 ++++++++++++++---------- 2 files changed, 139 insertions(+), 69 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 212297e..f7ab38f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2380,6 +2380,44 @@ export type GetShotsWithMetadataQuery = { }; }; +export type ShotFragmentFragment = { + __typename: "ShotGQL"; + id: number; + videoId: number; + startFrame: number; + endFrame: number; + falsePositiveScore?: number | null; + createdAt?: any | null; + updatedAt?: any | null; + user?: { __typename: "UserGQL"; id: number } | null; + video?: { + __typename: "VideoGQL"; + id: number; + stream?: { + __typename: "UploadStreamGQL"; + resolution: { + __typename: "VideoResolutionGQL"; + width?: number | null; + height?: number | null; + }; + } | null; + } | null; + cueObjectFeatures?: { + __typename: "CueObjectFeaturesGQL"; + cueObjectDistance?: number | null; + cueObjectAngle?: number | null; + cueBallSpeed?: number | null; + shotDirection?: ShotDirectionEnum | null; + spinType?: SpinTypeEnum | null; + } | null; + pocketingIntentionFeatures?: { + __typename: "PocketingIntentionFeaturesGQL"; + targetPocketDistance?: number | null; + make?: boolean | null; + intendedPocketType?: PocketEnum | null; + } | null; +}; + export type GetShotsByIdsQueryVariables = Exact<{ ids: Array | Scalars["Int"]["input"]; includeCreatedAt?: Scalars["Boolean"]["input"]; @@ -2399,7 +2437,7 @@ export type GetShotsByIdsQueryVariables = Exact<{ export type GetShotsByIdsQuery = { __typename?: "Query"; getShotsByIds: Array<{ - __typename?: "ShotGQL"; + __typename: "ShotGQL"; id: number; videoId: number; startFrame: number; @@ -2407,20 +2445,21 @@ export type GetShotsByIdsQuery = { falsePositiveScore?: number | null; createdAt?: any | null; updatedAt?: any | null; - user?: { __typename?: "UserGQL"; id: number } | null; + user?: { __typename: "UserGQL"; id: number } | null; video?: { - __typename?: "VideoGQL"; + __typename: "VideoGQL"; + id: number; stream?: { - __typename?: "UploadStreamGQL"; + __typename: "UploadStreamGQL"; resolution: { - __typename?: "VideoResolutionGQL"; + __typename: "VideoResolutionGQL"; width?: number | null; height?: number | null; }; } | null; } | null; cueObjectFeatures?: { - __typename?: "CueObjectFeaturesGQL"; + __typename: "CueObjectFeaturesGQL"; cueObjectDistance?: number | null; cueObjectAngle?: number | null; cueBallSpeed?: number | null; @@ -2428,7 +2467,7 @@ export type GetShotsByIdsQuery = { spinType?: SpinTypeEnum | null; } | null; pocketingIntentionFeatures?: { - __typename?: "PocketingIntentionFeaturesGQL"; + __typename: "PocketingIntentionFeaturesGQL"; targetPocketDistance?: number | null; make?: boolean | null; intendedPocketType?: PocketEnum | null; @@ -2979,6 +3018,48 @@ export type GetUploadStreamsWithDetailsQuery = { }; }; +export const ShotFragmentFragmentDoc = gql` + fragment ShotFragment on ShotGQL { + __typename + id + videoId + startFrame + endFrame + falsePositiveScore + createdAt + updatedAt + user { + __typename + id + } + video { + __typename + id + stream { + __typename + resolution { + __typename + width + height + } + } + } + cueObjectFeatures { + __typename + cueObjectDistance + cueObjectAngle + cueBallSpeed + shotDirection + spinType + } + pocketingIntentionFeatures { + __typename + targetPocketDistance + make + intendedPocketType + } + } +`; export const GetAggregatedShotMetricsDocument = gql` query GetAggregatedShotMetrics($aggregateInput: AggregateInputGQL!) { getAggregatedShotMetrics(aggregateInput: $aggregateInput) { @@ -3768,39 +3849,10 @@ export const GetShotsByIdsDocument = gql` $includeIntendedPocketType: Boolean! = false ) { getShotsByIds(ids: $ids) { - id - videoId - startFrame - endFrame - user { - id - } - falsePositiveScore - video { - stream { - resolution { - width - height - } - } - } - createdAt @include(if: $includeCreatedAt) - updatedAt @include(if: $includeUpdatedAt) - cueObjectFeatures @include(if: $includeCueObjectFeatures) { - cueObjectDistance @include(if: $includeCueObjectDistance) - cueObjectAngle @include(if: $includeCueObjectAngle) - cueBallSpeed @include(if: $includeCueBallSpeed) - shotDirection @include(if: $includeShotDirection) - spinType @include(if: $includeSpinType) - } - pocketingIntentionFeatures - @include(if: $includePocketingIntentionFeatures) { - targetPocketDistance @include(if: $includeTargetPocketDistance) - make @include(if: $includeMake) - intendedPocketType @include(if: $includeIntendedPocketType) - } + ...ShotFragment } } + ${ShotFragmentFragmentDoc} `; /** diff --git a/src/operations/shots.gql b/src/operations/shots.gql index 50b6773..2349053 100644 --- a/src/operations/shots.gql +++ b/src/operations/shots.gql @@ -139,6 +139,51 @@ query GetShotsWithMetadata( } } } +# shot.gql + +fragment ShotFragment on ShotGQL { + __typename + id + videoId + startFrame + endFrame + falsePositiveScore + createdAt + updatedAt + user { + __typename + id + # Add other necessary fields from UserGql if needed + } + video { + __typename + id + # Add other necessary fields from VideoGql if needed + stream { + __typename + resolution { + __typename + width + height + } + } + } + cueObjectFeatures { + __typename + cueObjectDistance + cueObjectAngle + cueBallSpeed + shotDirection + spinType + } + pocketingIntentionFeatures { + __typename + targetPocketDistance + make + intendedPocketType + } + # Add other nested fields as required +} query GetShotsByIds( $ids: [Int!]! @@ -156,36 +201,9 @@ query GetShotsByIds( $includeIntendedPocketType: Boolean! = false ) { getShotsByIds(ids: $ids) { - id - videoId - startFrame - endFrame - user { - id - } - falsePositiveScore - video { - stream { - resolution { - width - height - } - } - } - createdAt @include(if: $includeCreatedAt) - updatedAt @include(if: $includeUpdatedAt) - cueObjectFeatures @include(if: $includeCueObjectFeatures) { - cueObjectDistance @include(if: $includeCueObjectDistance) - cueObjectAngle @include(if: $includeCueObjectAngle) - cueBallSpeed @include(if: $includeCueBallSpeed) - shotDirection @include(if: $includeShotDirection) - spinType @include(if: $includeSpinType) - } - pocketingIntentionFeatures - @include(if: $includePocketingIntentionFeatures) { - targetPocketDistance @include(if: $includeTargetPocketDistance) - make @include(if: $includeMake) - intendedPocketType @include(if: $includeIntendedPocketType) - } + ...ShotFragment + # Since the fragment already includes all necessary fields, + # you can remove the conditional fields from the query itself. + # Alternatively, if you still need conditional fields, handle them within the fragment. } } From 301c017d5e2b88410e776de9ca91bb8185220180 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Mon, 30 Sep 2024 21:15:27 -0600 Subject: [PATCH 2/2] Delete unused varibles --- src/index.tsx | 85 ++++++++++------------------------------ src/operations/shots.gql | 34 ++-------------- 2 files changed, 23 insertions(+), 96 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index f7ab38f..65808fe 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2380,8 +2380,8 @@ export type GetShotsWithMetadataQuery = { }; }; -export type ShotFragmentFragment = { - __typename: "ShotGQL"; +export type ShotWithAllFeaturesFragment = { + __typename?: "ShotGQL"; id: number; videoId: number; startFrame: number; @@ -2389,21 +2389,21 @@ export type ShotFragmentFragment = { falsePositiveScore?: number | null; createdAt?: any | null; updatedAt?: any | null; - user?: { __typename: "UserGQL"; id: number } | null; + user?: { __typename?: "UserGQL"; id: number } | null; video?: { - __typename: "VideoGQL"; + __typename?: "VideoGQL"; id: number; stream?: { - __typename: "UploadStreamGQL"; + __typename?: "UploadStreamGQL"; resolution: { - __typename: "VideoResolutionGQL"; + __typename?: "VideoResolutionGQL"; width?: number | null; height?: number | null; }; } | null; } | null; cueObjectFeatures?: { - __typename: "CueObjectFeaturesGQL"; + __typename?: "CueObjectFeaturesGQL"; cueObjectDistance?: number | null; cueObjectAngle?: number | null; cueBallSpeed?: number | null; @@ -2411,7 +2411,7 @@ export type ShotFragmentFragment = { spinType?: SpinTypeEnum | null; } | null; pocketingIntentionFeatures?: { - __typename: "PocketingIntentionFeaturesGQL"; + __typename?: "PocketingIntentionFeaturesGQL"; targetPocketDistance?: number | null; make?: boolean | null; intendedPocketType?: PocketEnum | null; @@ -2420,24 +2420,12 @@ export type ShotFragmentFragment = { export type GetShotsByIdsQueryVariables = Exact<{ ids: Array | Scalars["Int"]["input"]; - includeCreatedAt?: Scalars["Boolean"]["input"]; - includeUpdatedAt?: Scalars["Boolean"]["input"]; - includeCueObjectFeatures?: Scalars["Boolean"]["input"]; - includePocketingIntentionFeatures?: Scalars["Boolean"]["input"]; - includeCueObjectDistance?: Scalars["Boolean"]["input"]; - includeCueObjectAngle?: Scalars["Boolean"]["input"]; - includeCueBallSpeed?: Scalars["Boolean"]["input"]; - includeSpinType?: Scalars["Boolean"]["input"]; - includeShotDirection?: Scalars["Boolean"]["input"]; - includeTargetPocketDistance?: Scalars["Boolean"]["input"]; - includeMake?: Scalars["Boolean"]["input"]; - includeIntendedPocketType?: Scalars["Boolean"]["input"]; }>; export type GetShotsByIdsQuery = { __typename?: "Query"; getShotsByIds: Array<{ - __typename: "ShotGQL"; + __typename?: "ShotGQL"; id: number; videoId: number; startFrame: number; @@ -2445,21 +2433,21 @@ export type GetShotsByIdsQuery = { falsePositiveScore?: number | null; createdAt?: any | null; updatedAt?: any | null; - user?: { __typename: "UserGQL"; id: number } | null; + user?: { __typename?: "UserGQL"; id: number } | null; video?: { - __typename: "VideoGQL"; + __typename?: "VideoGQL"; id: number; stream?: { - __typename: "UploadStreamGQL"; + __typename?: "UploadStreamGQL"; resolution: { - __typename: "VideoResolutionGQL"; + __typename?: "VideoResolutionGQL"; width?: number | null; height?: number | null; }; } | null; } | null; cueObjectFeatures?: { - __typename: "CueObjectFeaturesGQL"; + __typename?: "CueObjectFeaturesGQL"; cueObjectDistance?: number | null; cueObjectAngle?: number | null; cueBallSpeed?: number | null; @@ -2467,7 +2455,7 @@ export type GetShotsByIdsQuery = { spinType?: SpinTypeEnum | null; } | null; pocketingIntentionFeatures?: { - __typename: "PocketingIntentionFeaturesGQL"; + __typename?: "PocketingIntentionFeaturesGQL"; targetPocketDistance?: number | null; make?: boolean | null; intendedPocketType?: PocketEnum | null; @@ -3018,9 +3006,8 @@ export type GetUploadStreamsWithDetailsQuery = { }; }; -export const ShotFragmentFragmentDoc = gql` - fragment ShotFragment on ShotGQL { - __typename +export const ShotWithAllFeaturesFragmentDoc = gql` + fragment ShotWithAllFeatures on ShotGQL { id videoId startFrame @@ -3029,23 +3016,18 @@ export const ShotFragmentFragmentDoc = gql` createdAt updatedAt user { - __typename id } video { - __typename id stream { - __typename resolution { - __typename width height } } } cueObjectFeatures { - __typename cueObjectDistance cueObjectAngle cueBallSpeed @@ -3053,7 +3035,6 @@ export const ShotFragmentFragmentDoc = gql` spinType } pocketingIntentionFeatures { - __typename targetPocketDistance make intendedPocketType @@ -3833,26 +3814,12 @@ export type GetShotsWithMetadataQueryResult = Apollo.QueryResult< GetShotsWithMetadataQueryVariables >; export const GetShotsByIdsDocument = gql` - query GetShotsByIds( - $ids: [Int!]! - $includeCreatedAt: Boolean! = false - $includeUpdatedAt: Boolean! = false - $includeCueObjectFeatures: Boolean! = false - $includePocketingIntentionFeatures: Boolean! = false - $includeCueObjectDistance: Boolean! = false - $includeCueObjectAngle: Boolean! = false - $includeCueBallSpeed: Boolean! = false - $includeSpinType: Boolean! = false - $includeShotDirection: Boolean! = false - $includeTargetPocketDistance: Boolean! = false - $includeMake: Boolean! = false - $includeIntendedPocketType: Boolean! = false - ) { + query GetShotsByIds($ids: [Int!]!) { getShotsByIds(ids: $ids) { - ...ShotFragment + ...ShotWithAllFeatures } } - ${ShotFragmentFragmentDoc} + ${ShotWithAllFeaturesFragmentDoc} `; /** @@ -3868,18 +3835,6 @@ export const GetShotsByIdsDocument = gql` * const { data, loading, error } = useGetShotsByIdsQuery({ * variables: { * ids: // value for 'ids' - * includeCreatedAt: // value for 'includeCreatedAt' - * includeUpdatedAt: // value for 'includeUpdatedAt' - * includeCueObjectFeatures: // value for 'includeCueObjectFeatures' - * includePocketingIntentionFeatures: // value for 'includePocketingIntentionFeatures' - * includeCueObjectDistance: // value for 'includeCueObjectDistance' - * includeCueObjectAngle: // value for 'includeCueObjectAngle' - * includeCueBallSpeed: // value for 'includeCueBallSpeed' - * includeSpinType: // value for 'includeSpinType' - * includeShotDirection: // value for 'includeShotDirection' - * includeTargetPocketDistance: // value for 'includeTargetPocketDistance' - * includeMake: // value for 'includeMake' - * includeIntendedPocketType: // value for 'includeIntendedPocketType' * }, * }); */ diff --git a/src/operations/shots.gql b/src/operations/shots.gql index 2349053..c035ac7 100644 --- a/src/operations/shots.gql +++ b/src/operations/shots.gql @@ -139,10 +139,8 @@ query GetShotsWithMetadata( } } } -# shot.gql -fragment ShotFragment on ShotGQL { - __typename +fragment ShotWithAllFeatures on ShotGQL { id videoId startFrame @@ -151,25 +149,18 @@ fragment ShotFragment on ShotGQL { createdAt updatedAt user { - __typename id - # Add other necessary fields from UserGql if needed } video { - __typename id - # Add other necessary fields from VideoGql if needed stream { - __typename resolution { - __typename width height } } } cueObjectFeatures { - __typename cueObjectDistance cueObjectAngle cueBallSpeed @@ -177,33 +168,14 @@ fragment ShotFragment on ShotGQL { spinType } pocketingIntentionFeatures { - __typename targetPocketDistance make intendedPocketType } - # Add other nested fields as required } -query GetShotsByIds( - $ids: [Int!]! - $includeCreatedAt: Boolean! = false - $includeUpdatedAt: Boolean! = false - $includeCueObjectFeatures: Boolean! = false - $includePocketingIntentionFeatures: Boolean! = false - $includeCueObjectDistance: Boolean! = false - $includeCueObjectAngle: Boolean! = false - $includeCueBallSpeed: Boolean! = false - $includeSpinType: Boolean! = false - $includeShotDirection: Boolean! = false - $includeTargetPocketDistance: Boolean! = false - $includeMake: Boolean! = false - $includeIntendedPocketType: Boolean! = false -) { +query GetShotsByIds($ids: [Int!]!) { getShotsByIds(ids: $ids) { - ...ShotFragment - # Since the fragment already includes all necessary fields, - # you can remove the conditional fields from the query itself. - # Alternatively, if you still need conditional fields, handle them within the fragment. + ...ShotWithAllFeatures } }