MCPcopy Create free account
hub / github.com/glideapps/quicktype / removeNull

Function removeNull

src/GraphQL.ts:90–106  ·  view source on GitHub ↗
(builder: TypeBuilder, tref: TypeRef)

Source from the content-addressed store, hash-verified

88}
89
90function removeNull(builder: TypeBuilder, tref: TypeRef): TypeRef {
91 const t = tref.deref();
92 if (!(t instanceof UnionType)) {
93 return tref;
94 }
95 const nonNulls = removeNullFromUnion(t)[1];
96 const first = nonNulls.first();
97 if (first) {
98 if (nonNulls.size === 1) return first.typeRef;
99 return builder.getUnionType(
100 { names: t.names, alternatives: t.alternativeNames },
101 t.areNamesInferred,
102 nonNulls.map(nn => nn.typeRef)
103 );
104 }
105 return panic("Trying to remove null results in empty union.");
106}
107
108function makeScalar(builder: TypeBuilder, ft: GQLType): TypeRef {
109 switch (ft.name) {

Callers 1

GQLQueryClass · 0.85

Calls 3

removeNullFromUnionFunction · 0.90
panicFunction · 0.90
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…