MCPcopy Create free account
hub / github.com/github/docs / getTypeKind

Function getTypeKind

src/graphql/scripts/utils/schema-helpers.js:154–179  ·  view source on GitHub ↗
(type, schema)

Source from the content-addressed store, hash-verified

152}
153
154function getTypeKind(type, schema) {
155 type = removeMarkers(type)
156
157 const typeFromSchema = schema.getType(type)
158
159 if (isScalarType(typeFromSchema)) {
160 return 'scalars'
161 }
162 if (isObjectType(typeFromSchema)) {
163 return 'objects'
164 }
165 if (isInterfaceType(typeFromSchema)) {
166 return 'interfaces'
167 }
168 if (isUnionType(typeFromSchema)) {
169 return 'unions'
170 }
171 if (isEnumType(typeFromSchema)) {
172 return 'enums'
173 }
174 if (isInputObjectType(typeFromSchema)) {
175 return 'input-objects'
176 }
177
178 console.error(`cannot find type kind of ${type}`)
179}
180
181function removeMarkers(str) {
182 return str.replace('[', '').replace(']', '').replace(/!/g, '')

Callers 1

getArgumentsFunction · 0.85

Calls 1

removeMarkersFunction · 0.85

Tested by

no test coverage detected