Support new feature tables

This commit is contained in:
Kat Huang 2024-01-14 17:38:08 -07:00
parent afb2ef21f5
commit abfc6c4c47
4 changed files with 15 additions and 23 deletions

View File

@ -6,6 +6,7 @@ import ShotsContainer from "./component/shot";
const App: React.FC = () => { const App: React.FC = () => {
return ( return (
<ClientProvider> <ClientProvider>
<ShotsContainer />
<Text>test</Text> <Text>test</Text>
</ClientProvider> </ClientProvider>
); );

View File

@ -7,8 +7,6 @@ import {
from, from,
} from "@apollo/client"; } from "@apollo/client";
import { API_URI } from "@env"; import { API_URI } from "@env";
import { SHOT_FEATURES_FRAGMENT } from "./fragment/shot";
import { createFragmentRegistry } from "@apollo/client/cache";
type Props = { type Props = {
children: ReactNode; children: ReactNode;
@ -18,9 +16,7 @@ const ClientProvider: React.FC<Props> = ({ children }) => {
const httpLink = new HttpLink({ const httpLink = new HttpLink({
uri: API_URI, uri: API_URI,
}); });
const cache = new InMemoryCache({ const cache = new InMemoryCache({});
fragments: createFragmentRegistry(SHOT_FEATURES_FRAGMENT),
});
const client = new ApolloClient({ const client = new ApolloClient({
link: from([httpLink]), link: from([httpLink]),

View File

@ -1,13 +0,0 @@
import { gql } from "@apollo/client";
export const SHOT_FEATURES_FRAGMENT = gql`
fragment ShotFeatures on ShotFeaturesGQL {
cueObjectDistance @include(if: $includeCueObjectDistance)
targetPocketDistance @include(if: $includeTargetPocketDistance)
cueObjectAngle @include(if: $includeCueObjectAngle)
cueBallSpeed @include(if: $includeCueBallSpeed)
intendedPocket @include(if: $includeIntendedPocket)
shotDirection @include(if: $includeShotDirection)
didMake @include(if: $includeDidMake)
}
`;

View File

@ -4,12 +4,12 @@ export const GET_SHOTS = gql`
query GetShots( query GetShots(
$filterInput: FilterInput $filterInput: FilterInput
$includeCueObjectDistance: Boolean! = false $includeCueObjectDistance: Boolean! = false
$includeTargetPocketDistance: Boolean! = false
$includeCueObjectAngle: Boolean! = false $includeCueObjectAngle: Boolean! = false
$includeCueBallSpeed: Boolean! = false $includeCueBallSpeed: Boolean! = false
$includeIntendedPocket: Boolean! = false
$includeShotDirection: Boolean! = false $includeShotDirection: Boolean! = false
$includeDidMake: Boolean! = false $includeTargetPocketDistance: Boolean! = false
$includeMake: Boolean! = false
$includeIntendedPocketType: Boolean! = false
) { ) {
getShots(filterInput: $filterInput) { getShots(filterInput: $filterInput) {
id id
@ -18,8 +18,16 @@ export const GET_SHOTS = gql`
endFrame endFrame
createdAt createdAt
updatedAt updatedAt
features { cueObjectFeatures {
...ShotFeatures cueObjectDistance @include(if: $includeCueObjectDistance)
cueObjectAngle @include(if: $includeCueObjectAngle)
cueBallSpeed @include(if: $includeCueBallSpeed)
shotDirection @include(if: $includeShotDirection)
}
pocketingIntentionFeatures {
targetPocketDistance @include(if: $includeTargetPocketDistance)
make @include(if: $includeMake)
intendedPocketType @include(if: $includeIntendedPocketType)
} }
} }
} }