Skip to content

Commit

Permalink
Passing view tests with the new GQL types from swift
Browse files Browse the repository at this point in the history
  • Loading branch information
Dracks committed Sep 18, 2024
1 parent d93e2d9 commit 0c38662
Show file tree
Hide file tree
Showing 24 changed files with 624 additions and 535 deletions.
14 changes: 4 additions & 10 deletions config/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ generates:
withHooks: true
typesPrefix: GQL
nonOptionalTypename: false
src/server/common/test-graphql/generated.ts:
plugins:
- typescript
- typescript-urql
- typescript-operations
config:
withComponent: false
withHooks: false
typesPrefix: GQL
nonOptionalTypename: false
scalars:
Date: Date
DateOnly: string
UUID: string
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TscWatchClient } from 'tsc-watch/client';
import webpack from 'webpack';

import WebpackConfig from '../config/webpack.config';

/*
const tsc = new TscWatchClient();
// eslint-disable-next-line init-declarations
Expand All @@ -19,7 +19,7 @@ tsc.on('success', () => {
});
tsc.start('--project', './tsconfig.server.json');

*/
WebpackConfig.watch = true;

webpack(WebpackConfig, (err, stats) => {
Expand All @@ -37,5 +37,3 @@ webpack(WebpackConfig, (err, stats) => {
}),
);
});

//*/
7 changes: 2 additions & 5 deletions src/view/api/client/graphs/delete-graph.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
mutation deleteGraph($graphId: Int!) {
mutation deleteGraph($graphId: UUID!) {
deleteGraph(graphId: $graphId){
__typename,
... on InvalidGraph {
availableGraphsId
}
}
}
}
4 changes: 2 additions & 2 deletions src/view/api/client/graphs/get-graphs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ query getGraphs {
}


query getGraphsById($graphsIds: [Int!]) {
graphs(graphsIds: $graphsIds) {
query getGraphsById($graphsIds: [UUID!]) {
graphs(graphIds: $graphsIds) {
...GraphFragment
}
}
17 changes: 10 additions & 7 deletions src/view/api/client/graphs/mocks/graph-v2.mocks.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { listLabelIds } from '../../../../utils/data-factory/label.factory';
import { mainGroupOwnerId } from '../../../../utils/data-factory/user-group.factory';
import { GQLGraph, GQLGraphDateRange, GQLGraphGroup, GQLGraphKind } from '../../../graphql/generated';


export const GraphV2Pie: Omit<GQLGraph, 'id'> = {
dateRange: GQLGraphDateRange.All,
group: {
group: GQLGraphGroup.Labels,
labels: [4, 5, 8],
labels: [4, 5, 8].map(idx => listLabelIds[idx]),
},
groupOwnerId: 1,
groupOwnerId: mainGroupOwnerId,
kind: GQLGraphKind.Pie,
labelFilter: 2,
labelFilterId: listLabelIds[2],
name: 'Percentatge',
};

Expand All @@ -17,13 +20,13 @@ export const GraphV2Line: Omit<GQLGraph, 'id'> = {
group: {
group: GQLGraphGroup.Month,
},
groupOwnerId: 1,
groupOwnerId: mainGroupOwnerId,
horizontalGroup: {
accumulate: true,
group: GQLGraphGroup.Day,
},
kind: GQLGraphKind.Line,
labelFilter: 2,
labelFilterId: listLabelIds[2],
name: 'Compare by day',
};

Expand All @@ -32,12 +35,12 @@ export const GraphV2Bar: Omit<GQLGraph, 'id'> = {
group: {
group: GQLGraphGroup.Sign,
},
groupOwnerId: 1,
groupOwnerId: mainGroupOwnerId,
horizontalGroup: {
accumulate: false,
group: GQLGraphGroup.Month,
},
kind: GQLGraphKind.Bar,
labelFilter: 1,
labelFilterId: listLabelIds[1],
name: 'Income vs outcome',
};
2 changes: 1 addition & 1 deletion src/view/api/client/graphs/new-graph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mutation newGraph($graph: NewGraph!){
... on WrongOwnerId{
...WrongOwnerIdFragment
},
... on InvalidLabel{
... on InvalidLabels{
...InvalidLabelFragment
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/view/api/client/graphs/update-graph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ mutation updateGraph($graph: UpdateGraph!){
... on WrongOwnerId{
...WrongOwnerIdFragment
},
... on InvalidLabel{
... on InvalidLabels{
...InvalidLabelFragment
}
... on InvalidGraph {
availableGraphsId
}
}
}
4 changes: 2 additions & 2 deletions src/view/api/client/labels/invalid-label.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fragment InvalidLabelFragment on InvalidLabel {
fragment InvalidLabelFragment on InvalidLabels {
invalidLabels
}
}
Loading

0 comments on commit 0c38662

Please sign in to comment.