src/utility/fillLeafs.js
function defaultGetDefaultFieldNames(type) {
  // If this type cannot access fields, then return an empty set.
  if (!type.getFields) {
    return [];
  }

  const fields = type.getFields();

  // Is there an `id` field?
  if (fields['id']) {
    return ['id'];
  }

  // Is there an `edges` field?
  if (fields['edges']) {
    return ['edges'];
  }

  // Is there an `node` field?
  if (fields['node']) {
    return ['node'];
  }

  // Include all leaf-type fields.
  const leafFieldNames = [];
  Object.keys(fields).forEach(fieldName => {
    if (isLeafType(fields[fieldName].type)) {
      leafFieldNames.push(fieldName);
    }
  });
  return leafFieldNames;
}
function defaultGetDefaultFieldNames(type) {
  // If this type cannot access fields, then return an empty set.
  if (!type.getFields) {
    return [];
  }

  const fields = type.getFields();

  // Is there an `id` field?
  if (fields['id']) {
    return ['id'];
  }

  // Is there an `edges` field?
  if (fields['edges']) {
    return ['edges'];
  }

  // Is there an `node` field?
  if (fields['node']) {
    return ['node'];
  }

  // Include all leaf-type fields.
  const leafFieldNames = [];
  Object.keys(fields).forEach(fieldName => {
    if (isLeafType(fields[fieldName].type)) {
      leafFieldNames.push(fieldName);
    }
  });
  return leafFieldNames;
}
function defaultGetDefaultFieldNames ( type ) { // If this type cannot access fields, then return an empty set. if ( ! type . getFields ) { return [ ] ; } const fields = type . getFields ( ) ; // Is there an `id` field? if ( fields [ 'id' ] ) { return [ 'id' ] ; } // Is there an `edges` field? if ( fields [ 'edges' ] ) { return [ 'edges' ] ; } // Is there an `node` field? if ( fields [ 'node' ] ) { return [ 'node' ] ; } // Include all leaf-type fields. const leafFieldNames = [ ] ; Object . keys ( fields ) . forEach ( fieldName => { if ( isLeafType ( fields [ fieldName ] . type ) ) { leafFieldNames . push ( fieldName ) ; } } ) ; return leafFieldNames ; }
The default function to use for producing the default fields from a type. This function first looks for some common patterns, and falls back to including all leaf-type fields.
The default function to use for producing the default fields from a type . This function first looks for some common patterns and falls back to including all leaf - type fields .