INNER CODE UNIT · TypeScript
getGraphQLInsertType
OS-Guild/graphql-to-mongodb · src/graphQLInsertType.ts:5
export function getGraphQLInsertType(graphQLType: GraphQLObjectType, ...excludedFields: string[]) : GraphQLInputObjectType {
const inputTypeName = setSuffix(graphQLType.name, 'Type', 'InsertType');
return cache(typesCache, inputTypeName, () => new GraphQLInputObjectType({
name: inputTypeName,
fields: getGraphQLInsertTypeFields(graphQLType, ...excludedFields)
}));
}
function getGraphQLInsertTypeFields(graphQLType: GraphQLObjectType, ...excludedFields: string[]) : () => FieldMap<GraphQLInputType> {
return () => {
const fields = getUnresolvedFieldsTypes(graphQLType, getGraphQLInsertTypeNested, ...excludedFields)();
const idField = fields['_id'];
if (idField && idField.type instanceof GraphQLNonNull) {
idField.type = idField.type.ofType;
}