INNER CODE UNIT · TypeScript

getGraphQLLeafFilterType

OS-Guild/graphql-to-mongodb · src/graphQLFilterType.ts:89

function getGraphQLLeafFilterType(leafType: GraphQLLeafType, not: boolean = false): GraphQLInputObjectType {
    const typeName = leafType.toString() + (not ? `Not` : '') + `Filter`;

    return cache(typesCache, typeName, () => new GraphQLInputObjectType({
        name: typeName,
        description: `Filter type for ${(not ? `$not of ` : '')}${leafType} scalar`,
        fields: getGraphQLScalarFilterTypeFields(leafType, not)
    }));
}

function getGraphQLScalarFilterTypeFields(scalarType: GraphQLLeafType, not: boolean): GraphQLInputFieldConfigMap {
    const fields = {
        EQ: { type: scalarType, description: '$eq' },
        GT: { type: scalarType, description: '$gt' },
        GTE: { type: scalarType, description: '$gte' },
        IN: { type: new GraphQLList(scalarType), description: '$in' },
        ALL: { type: new GraphQLList(scalarType), description: '$all' },
        LT: { type: scalarType, description: '$lt' },

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…