src/type/type.js
function getOrderByType({ name }, fields) {
  if (!orderByTypes[name]) {
    // save new enum
    orderByTypes[name] = new GraphQLEnumType({
      name: `orderBy${name}`,
      values: reduce(fields, (values, field) => {
        if (field.type instanceof GraphQLScalarType) {
          const upperCaseName = field.name.toUpperCase();
          values[`${upperCaseName}_ASC`] = {
            name: `${upperCaseName}_ASC`,
            value: {
              [field.name]: 1
            }
          };
          values[`${upperCaseName}_DESC`] = {
            name: `${upperCaseName}_DESC`,
            value: {
              [field.name]: -1
            }
          };
        }

        return values;
      }, {})
    });
  }
  return orderByTypes[name];
}
function getOrderByType({ name }, fields) {
  if (!orderByTypes[name]) {
    // save new enum
    orderByTypes[name] = new GraphQLEnumType({
      name: `orderBy${name}`,
      values: reduce(fields, (values, field) => {
        if (field.type instanceof GraphQLScalarType) {
          const upperCaseName = field.name.toUpperCase();
          values[`${upperCaseName}_ASC`] = {
            name: `${upperCaseName}_ASC`,
            value: {
              [field.name]: 1
            }
          };
          values[`${upperCaseName}_DESC`] = {
            name: `${upperCaseName}_DESC`,
            value: {
              [field.name]: -1
            }
          };
        }

        return values;
      }, {})
    });
  }
  return orderByTypes[name];
}
function getOrderByType ( { name } , fields ) { if ( ! orderByTypes [ name ] ) { // save new enum orderByTypes [ name ] = new GraphQLEnumType ( { name : ` ${ name } ` , values : reduce ( fields , ( values , field ) => { if ( field . type instanceof GraphQLScalarType ) { const upperCaseName = field . name . toUpperCase ( ) ; values [ ` ${ upperCaseName } ` ] = { name : ` ${ upperCaseName } ` , value : { [ field . name ] : 1 } } ; values [ ` ${ upperCaseName } ` ] = { name : ` ${ upperCaseName } ` , value : { [ field . name ] : - 1 } } ; } return values ; } , { } ) } ) ; } return orderByTypes [ name ] ; }
Returns order by GraphQLEnumType for fields
@param  {{String}} {name}
@param  {Object} fields
@return {GraphQLEnumType}
Returns order by GraphQLEnumType for fields