MCPcopy Index your code
hub / github.com/cloudgraphdev/cli / processGQLExecutionResult

Function processGQLExecutionResult

src/storage/dgraph/utils.ts:80–137  ·  view source on GitHub ↗
({
  errors: resErrors,
  reqData = { query: '', variables: {} },
  resData,
  service,
}: {
  errors?: ReadonlyArray<GraphQLError>
  reqData?: GraphQLFormattedQuery
  resData?: { [key: string]: any } | null
  service?: string
})

Source from the content-addressed store, hash-verified

78}
79
80export function processGQLExecutionResult({
81 errors: resErrors,
82 reqData = { query: '', variables: {} },
83 resData,
84 service,
85}: {
86 errors?: ReadonlyArray<GraphQLError>
87 reqData?: GraphQLFormattedQuery
88 resData?: { [key: string]: any } | null
89 service?: string
90}): void {
91 // Data interpolated to query. Works for both schema push and data load
92 const { variables } = reqData
93 if (resData && !resErrors) {
94 const { data: mutationResultData, errors: dataErrors } = resData
95 let executedMutationNames: string[] = []
96 if (!isEmpty(mutationResultData)) {
97 executedMutationNames = Object.keys(mutationResultData) || []
98 if (
99 !isEmpty(executedMutationNames) &&
100 executedMutationNames[0].includes('add')
101 ) {
102 executedMutationNames.forEach(mutationName => {
103 if (mutationResultData[mutationName]) {
104 const { numUids } = mutationResultData[mutationName]
105 const numUidsString = numUids ? `numUids affected: ${numUids}` : ''
106 logger.debug(
107 `mutation ${chalk.green(
108 mutationName
109 )} completed successfully. ${numUidsString}`
110 )
111 }
112 })
113 }
114 // Leaving this block here in case we need/want
115 // to print the output the result of the patch mutations
116 //
117 // if (executedMutationNames[0].includes('update')) {
118 // executedMutationNames.forEach(mutation => {
119 // const serviceName = mutation.split('update')[1]
120 // const filter = mutationResultData[mutation][serviceName]
121 // if (filter && filter[0]) {
122 // const { id } = filter[0]
123 // logger.debug(`Connections added for id ${chalk.green(id)}.`)
124 // }
125 // })
126 // }
127 }
128 processErrorArrayIfExists({
129 errors: dataErrors,
130 variables,
131 additionalInfo: { executedMutationNames },
132 service,
133 })
134 }
135 // Data related errors
136 processErrorArrayIfExists({ errors: resErrors, variables, service })
137}

Callers 4

setSchemaMethod · 0.90
getSchemaMethod · 0.90
pushMethod · 0.90
runMethod · 0.90

Calls 1

Tested by

no test coverage detected