1
- import { useMutation , useQuery } from '@apollo/client'
1
+ import { useQuery } from '@apollo/client'
2
2
import { Box } from 'grommet'
3
3
import { Flex , Span } from 'honorable'
4
4
import moment from 'moment'
@@ -25,11 +25,15 @@ import { Table, TableData, TableRow } from '../utils/Table'
25
25
import ListInput from '../utils/ListInput'
26
26
import { List } from '../utils/List'
27
27
import { Confirm } from '../utils/Confirm'
28
- import { DnsRecordFragment } from '../../generated/graphql'
28
+ import {
29
+ DnsRecordFragment ,
30
+ useDeleteDomainMutation ,
31
+ useUpdateDomainMutation ,
32
+ } from '../../generated/graphql'
29
33
30
34
import LoadingIndicator from '../utils/LoadingIndicator'
31
35
32
- import { DELETE_DOMAIN , DNS_DOMAINS , UPDATE_DOMAIN } from './queries'
36
+ import { DNS_DOMAINS } from './queries'
33
37
import { Actions } from './Actions'
34
38
import { MoreMenu } from './MoreMenu'
35
39
import { BindingInput } from './Typeaheads'
@@ -52,12 +56,13 @@ function Header({ q, setQ }: any) {
52
56
function DomainOptions ( { domain, setDomain } : any ) {
53
57
const [ confirm , setConfirm ] = useState ( false )
54
58
const [ edit , setEdit ] = useState ( false )
55
- const [ mutation , { loading, error } ] = useMutation ( DELETE_DOMAIN , {
59
+ const [ mutation , { loading, error } ] = useDeleteDomainMutation ( {
56
60
variables : { id : domain . id } ,
57
- update : ( cache , { data : { deleteDomain } } ) => {
61
+ update : ( cache , { data } ) => {
58
62
updateCache ( cache , {
59
63
query : DNS_DOMAINS ,
60
- update : ( prev ) => removeConnection ( prev , deleteDomain , 'dnsDomains' ) ,
64
+ update : ( prev ) =>
65
+ removeConnection ( prev , data ?. deleteDomain , 'dnsDomains' ) ,
61
66
variables : { } ,
62
67
} )
63
68
} ,
@@ -124,7 +129,7 @@ function AccessPolicy({ domain: { id, accessPolicy }, edit, setEdit }: any) {
124
129
accessPolicy ? accessPolicy . bindings : [ ]
125
130
)
126
131
const uniqueBindings = useMemo ( ( ) => uniqWith ( bindings , isEqual ) , [ bindings ] )
127
- const [ mutation , { loading, error } ] = useMutation ( UPDATE_DOMAIN , {
132
+ const [ mutation , { loading, error } ] = useUpdateDomainMutation ( {
128
133
variables : {
129
134
id,
130
135
attributes : {
0 commit comments