Skip to content

Commit a744999

Browse files
refactor: remove concept of liveMutation (#19528)
* refactor: remove the concept of liveMutation * fix types * Fix types * add missing cache key Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
1 parent 3f936fb commit a744999

File tree

21 files changed

+120
-151
lines changed

21 files changed

+120
-151
lines changed

packages/app/src/composables/usePreferences.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { useRunnerUiStore, RunnerUiState } from '../store'
22
import { useMutation, gql } from '@urql/vue'
3-
import { Preferences_SetPreferencesDocument } from '@packages/data-context/src/gen/all-operations.gen'
3+
import { Preferences_SetPreferencesDocument } from '@packages/app/src/generated/graphql'
44

55
const runnerUiStore = useRunnerUiStore()
66

77
gql`
88
mutation Preferences_SetPreferences ($value: String!) {
9-
setPreferences (value: $value)
9+
setPreferences (value: $value) {
10+
...TestingPreferences
11+
...SpecRunner_Preferences
12+
}
1013
}`
1114

1215
export function usePreferences () {

packages/app/src/runner/SpecRunner.vue

+13-7
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,7 @@ import { runnerConstants } from './runner-constants'
107107
const { height: windowHeight, width: windowWidth } = useWindowSize()
108108
109109
gql`
110-
fragment SpecRunner on Query {
111-
...Specs_InlineSpecList
112-
currentProject {
113-
id
114-
...SpecRunnerHeader
115-
}
116-
...ChooseExternalEditor
110+
fragment SpecRunner_Preferences on Query {
117111
localSettings {
118112
preferences {
119113
isSpecsListOpen
@@ -125,6 +119,18 @@ fragment SpecRunner on Query {
125119
}
126120
`
127121
122+
gql`
123+
fragment SpecRunner on Query {
124+
...Specs_InlineSpecList
125+
currentProject {
126+
id
127+
...SpecRunnerHeader
128+
}
129+
...ChooseExternalEditor
130+
...SpecRunner_Preferences
131+
}
132+
`
133+
128134
gql`
129135
mutation OpenFileInIDE ($input: FileDetailsInput!) {
130136
openFileInIDE (input: $input)

packages/app/src/runner/SpecRunnerHeader.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ mutation SpecRunnerHeader_SetBrowser($browserId: ID!, $specPath: String!) {
114114
isSelected
115115
}
116116
}
117-
launchOpenProject(specPath: $specPath)
117+
launchOpenProject(specPath: $specPath) {
118+
id
119+
}
118120
}
119121
`
120122

packages/app/src/settings/device/ExternalEditorSettings.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import { useMutation } from '@urql/vue'
2525
2626
gql`
2727
mutation ExternalEditorSettings_SetPreferredEditorBinary ($value: String!) {
28-
setPreferences (value: $value)
28+
setPreferences (value: $value) {
29+
...ExternalEditorSettings
30+
}
2931
}`
3032
3133
const { t } = useI18n()

packages/app/src/settings/device/TestingPreferences.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ fragment TestingPreferences on Query {
5151
5252
gql`
5353
mutation SetTestingPreferences($value: String!) {
54-
setPreferences (value: $value)
54+
setPreferences (value: $value) {
55+
...TestingPreferences
56+
}
5557
}`
5658
5759
const setPreferences = useMutation(SetTestingPreferencesDocument)

packages/data-context/src/util/urqlCacheKeys.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const urqlCacheKeys: Partial<CacheExchangeOpts> = {
1313
App: (data) => data.__typename,
1414
DevState: (data) => data.__typename,
1515
Wizard: (data) => data.__typename,
16+
Migration: (data) => data.__typename,
1617
Warning: (data) => null,
1718
CloudRunCommitInfo: () => null,
1819
GitInfo: () => null,

packages/frontend-shared/cypress/support/mock-graphql/stubgql-Mutation.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export const stubMutation: MaybeResolver<Mutation> = {
99
addProject (source, args, ctx) {
1010
ctx.projects.push(createTestGlobalProject(path.basename(args.path)))
1111

12-
return true
12+
return {}
1313
},
1414
setCurrentProject (source, args, ctx) {
1515
const project = ctx.projects.find((p) => p.projectRoot === args.path)
1616

1717
ctx.currentProject = project ? createTestCurrentProject(project.title) : null
1818

19-
return true
19+
return {}
2020
},
2121
clearCurrentProject (source, args, ctx) {
2222
ctx.currentProject = null
@@ -26,7 +26,7 @@ export const stubMutation: MaybeResolver<Mutation> = {
2626
removeProject (source, args, ctx) {
2727
ctx.projects = ctx.projects.filter((p) => p.projectRoot !== args.path)
2828

29-
return true
29+
return {}
3030
},
3131
hideBrowserWindow (source, args, ctx) {
3232
return true

packages/frontend-shared/src/gql-components/Auth.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,17 @@ fragment Auth on Query {
6767
6868
gql`
6969
mutation Logout {
70-
logout
70+
logout {
71+
...Auth
72+
}
7173
}
7274
`
7375
7476
gql`
7577
mutation Login {
76-
login
78+
login {
79+
...Auth
80+
}
7781
}
7882
`
7983

packages/frontend-shared/src/gql-components/ChooseExternalEditorModal.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ fragment ChooseExternalEditorModal on Query {
5959
6060
gql`
6161
mutation ChooseExternalEditorModal_SetPreferredEditorBinary ($value: String!) {
62-
setPreferences (value: $value)
62+
setPreferences (value: $value) {
63+
localSettings {
64+
preferences {
65+
preferredEditorBinary
66+
}
67+
}
68+
}
6369
}`
6470
6571
const setPreferredBinaryEditor = useMutation(ChooseExternalEditorModal_SetPreferredEditorBinaryDocument)

packages/frontend-shared/src/gql-components/topnav/TopNav.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,10 @@ fragment TopNav on Query {
278278
`
279279
280280
gql`
281-
mutation TopNav_LaunchOpenProject {
282-
launchOpenProject
281+
mutation TopNav_LaunchOpenProject {
282+
launchOpenProject {
283+
id
284+
}
283285
}
284286
`
285287

packages/graphql/schemas/schema.graphql

+8-14
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,7 @@ type Mutation {
610610
"""Whether to open the project when added"""
611611
open: Boolean
612612
path: String!
613-
): Boolean
614-
615-
"""Create an Index HTML file for a new component testing project"""
616-
appCreateComponentIndexHtml(template: String!): Boolean
613+
): Query
617614

618615
"""Clears the currently active project"""
619616
clearCurrentProject: Query
@@ -641,7 +638,7 @@ type Mutation {
641638
internal_clearProjectPreferencesCache(projectTitle: String!): Boolean
642639

643640
"""Launches project from open_project global singleton"""
644-
launchOpenProject(specPath: String): Boolean
641+
launchOpenProject(specPath: String): CurrentProject
645642

646643
"""Sets the active browser"""
647644
launchpadSetBrowser(
@@ -650,10 +647,10 @@ type Mutation {
650647
): CurrentProject
651648

652649
"""Auth with Cypress Cloud"""
653-
login: Boolean
650+
login: Query
654651

655652
"""Log out of Cypress Cloud"""
656-
logout: Boolean
653+
logout: Query
657654

658655
"""Open a path in preferred IDE"""
659656
openDirectoryInIDE(path: String!): Boolean
@@ -669,30 +666,27 @@ type Mutation {
669666
reconfigureProject: Boolean!
670667

671668
"""Remove project from projects array and cache"""
672-
removeProject(path: String!): Boolean
669+
removeProject(path: String!): Query
673670

674671
"""Reset the Wizard to the starting position"""
675672
resetWizard: Boolean!
676673
scaffoldIntegration: [CodeGenResultWithFileParts!]!
677674
scaffoldTestingType: Query
678675

679676
"""Set active project to run tests on"""
680-
setCurrentProject(path: String!): Boolean
677+
setCurrentProject(path: String!): Query
681678
setCurrentTestingType(testingType: TestingTypeEnum!): Query
682679

683680
"""
684681
Update local preferences (also known as appData). The payload, `value`, should be a `JSON.stringified()` object of the new values you'd like to persist. Example: `setPreferences (value: JSON.stringify({ lastOpened: Date.now() }))`
685682
"""
686-
setPreferences(value: String!): Boolean
683+
setPreferences(value: String!): Query
687684

688685
"""Save the projects preferences to cache"""
689686
setProjectPreferences(browserPath: String!, testingType: TestingTypeEnum!): Query!
690687

691-
"""show the launchpad at the browser picker step"""
692-
showElectronOnAppExit: Boolean
693-
694688
"""Updates the different fields of the wizard data store"""
695-
wizardUpdate(input: WizardUpdateInput!): Boolean
689+
wizardUpdate(input: WizardUpdateInput!): Wizard
696690
}
697691

698692
"""Implements the Relay Node spec"""

packages/graphql/src/plugins/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable padding-line-between-statements */
22
// created by autobarrel, do not modify directly
33

4-
export * from './nexusLiveMutation'
54
export * from './nexusNodePlugin'

packages/graphql/src/plugins/nexusLiveMutation.ts

-75
This file was deleted.

packages/graphql/src/schema.ts

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { makeSchema, connectionPlugin } from 'nexus'
44
import * as schemaTypes from './schemaTypes/'
55
import { nodePlugin } from './plugins/nexusNodePlugin'
66
import { remoteSchemaWrapped } from './stitching/remoteSchemaWrapped'
7-
import { NexusLiveMutationPlugin } from './plugins/nexusLiveMutation'
87

98
const isCodegen = Boolean(process.env.CYPRESS_INTERNAL_NEXUS_CODEGEN)
109

@@ -36,7 +35,6 @@ export const graphqlSchema = makeSchema({
3635
},
3736
}),
3837
nodePlugin,
39-
NexusLiveMutationPlugin,
4038
],
4139
formatTypegen (content, type) {
4240
if (type === 'schema') {

0 commit comments

Comments
 (0)