Skip to content

Commit

Permalink
fix: refactor new api name to cacheWriteQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
playerx committed Mar 19, 2020
1 parent c4e4d2a commit 61e1051
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import getTypescriptPropsTypeName from '../../domain/getTypescriptPropsTypeName'
import uncapitalizeFirstLetter from '../../utils/uncapitalizeFirstLetter'
import generatePropsType from '../helper/generatePropsType'
import generateResultTypeFields from '../helper/generateResultTypeFields'
import cacheWriteQuery from '../render/cacheWriteQuery'
import renderFragment from '../render/renderFragment'
import renderMethod from '../render/renderMethod'
import renderOptions from '../render/renderOptions'
import renderQuery from '../render/renderQuery'
import updateCacheQuery from '../render/updateCacheQuery'

export default function (
field: IntrospectionField,
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function (
const type = <IntrospectionType>types.find(x => x.name === returnGraphqlTypeName)

const method = renderMethod({
rootType: 'updateCacheQuery',
rootType: 'cacheWriteQuery',
methodName: methodName,
generateDefaultFragments,
hasProps: hasInputs,
Expand All @@ -62,7 +62,7 @@ export default function (
variablesDeclarationString,
variablesString,
}) +
updateCacheQuery({
cacheWriteQuery({
hasProps: hasInputs,
queryName,
}),
Expand Down
4 changes: 2 additions & 2 deletions src/commands/graphql-client/generator/generateProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function (
const generatedQuery = generateRootType(RootType.Query, otherTypes, generateDefaultFragments)(queryType)
const generatedWatchQuery = generateRootType('watchQuery', otherTypes, generateDefaultFragments)(queryType)
const generatedRefetchQuery = generateRootType('refetchQuery', otherTypes, generateDefaultFragments)(queryType)
const generatedUpdateCache = generateRootType('updateCacheQuery', otherTypes, generateDefaultFragments)(queryType)
const generatedCacheWriteQuery = generateRootType('cacheWriteQuery', otherTypes, generateDefaultFragments)(queryType)
const generatedMutation = generateRootType(RootType.Mutation, otherTypes, generateDefaultFragments)(mutationType)
const generatedSubscription =
generateRootType(RootType.Subscription, otherTypes, generateDefaultFragments)(subscriptionType)
Expand All @@ -55,7 +55,7 @@ export default function (
generatedQuery,
generatedWatchQuery,
generatedRefetchQuery,
generatedUpdateCache,
generatedCacheWriteQuery,
generatedMutation,
generatedSubscription,
generatedOtherTypes,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/graphql-client/generator/generateRootType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import generateMutationMethod from './generate/generateMutationMethod'
import generateQueryMethod from './generate/generateQueryMethod'
import generateRefetchQueryMethod from './generate/generateRefetchQueryMethod'
import generateSubscriptionMethod from './generate/generateSubscriptionMethod'
import generateUpdateCacheQueryMethod from './generate/generateUpdateCacheQueryMethod'
import generateCacheWriteQueryMethod from './generate/generateUpdateCacheQueryMethod'
import generateWatchQueryMethod from './generate/generateWatchQueryMethod'
import renderRootTypeClass from './render/renderRootTypeClass'

export default (
typeName: RootType | 'watchQuery' | 'refetchQuery' | 'updateCacheQuery',
typeName: RootType | 'watchQuery' | 'refetchQuery' | 'cacheWriteQuery',
otherTypes: IntrospectionType[],
generateDefaultFragments: boolean,
) => (queryType: IntrospectionType) => {
Expand All @@ -27,7 +27,7 @@ export default (
[RootType.Query.toString()]: generateQueryMethod,
['watchQuery']: generateWatchQueryMethod,
['refetchQuery']: generateRefetchQueryMethod,
['updateCacheQuery']: generateUpdateCacheQueryMethod,
['cacheWriteQuery']: generateCacheWriteQueryMethod,
[RootType.Mutation.toString()]: generateMutationMethod,
[RootType.Subscription.toString()]: generateSubscriptionMethod,
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/graphql-client/generator/render/renderMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export default function ({
const omittedOptionsType = {
[RootType.Query]: 'OmittedQueryOptions',
watchQuery: 'OmittedWatchQueryOptions',
updateCacheQuery: 'OmittedQueryOptions',
cacheWriteQuery: 'OmittedQueryOptions',
[RootType.Mutation]: 'OmittedMutationOptions',
[RootType.Subscription]: 'OmittedSubscriptionOptions',
}[rootType]

const isUpdateCacheMode = rootType === 'updateCacheQuery'
const isCacheWriteQueryMode = rootType === 'cacheWriteQuery'

const fragmentRequiredSymbol = generateDefaultFragments ? '?' : ''

Expand All @@ -40,7 +40,7 @@ export default function ({
return `
${methodName}(
${hasProps ? `props: ${propsType},` : ``}
${isUpdateCacheMode
${isCacheWriteQueryMode
? `data: any,
${fragmentProp}`
: `
Expand Down
10 changes: 5 additions & 5 deletions src/commands/graphql-client/generator/render/renderProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function ({
generatedQuery,
generatedWatchQuery,
generatedRefetchQuery,
generatedUpdateCache,
generatedCacheWriteQuery,
generatedMutation,
generatedSubscription,
generatedQueryTypesEnum,
Expand All @@ -23,7 +23,7 @@ ${generatedOtherTypes}
${generatedQuery || ''}
${generatedWatchQuery || ''}
${generatedRefetchQuery || ''}
${generatedUpdateCache || ''}
${generatedCacheWriteQuery || ''}
${generatedMutation || ''}
${generatedSubscription || ''}
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface Client {
${generatedQuery ? 'query: Query' : ''}
${generatedWatchQuery ? 'watchQuery: WatchQuery' : ''}
${generatedRefetchQuery ? 'refetchQuery: RefetchQuery' : ''}
${generatedUpdateCache ? 'updateCacheQuery: UpdateCacheQuery' : ''}
${generatedCacheWriteQuery ? 'cacheWriteQuery: cacheWriteQuery' : ''}
${generatedMutation ? 'mutation: Mutation' : ''}
${generatedSubscription ? 'subscription: Subscription' : ''}
}
Expand All @@ -94,8 +94,8 @@ export default function (client: ApolloClient<any>, defaultOptions: DefaultOptio
: ''
}
${
generatedUpdateCache
? 'updateCacheQuery: new UpdateCacheQuery(client, defaultOptions.query || {}),'
generatedCacheWriteQuery
? 'cacheWriteQuery: new cacheWriteQuery(client, defaultOptions.query || {}),'
: ''
}
${
Expand Down

0 comments on commit 61e1051

Please sign in to comment.