function hasID(schema: GraphQLSchema, type: GraphQLCompositeType): boolean {
  const unmodifiedType = getRawType(type);
  invariant(
    unmodifiedType instanceof GraphQLObjectType ||
      unmodifiedType instanceof GraphQLInterfaceType,
    'GraphQLSchemaUtils.hasID(): Expected a concrete type or interface, ' +
      'got type `%s`.',
    type,
  );
  const idType = schema.getType(ID_TYPE);
  const idField = unmodifiedType.getFields()[ID];
  return idField && getRawType(idField.type) === idType;
}
function hasID(schema: GraphQLSchema, type: GraphQLCompositeType): boolean {
  const unmodifiedType = getRawType(type);
  invariant(
    unmodifiedType instanceof GraphQLObjectType ||
      unmodifiedType instanceof GraphQLInterfaceType,
    'GraphQLSchemaUtils.hasID(): Expected a concrete type or interface, ' +
      'got type `%s`.',
    type,
  );
  const idType = schema.getType(ID_TYPE);
  const idField = unmodifiedType.getFields()[ID];
  return idField && getRawType(idField.type) === idType;
}
function hasID ( schema : GraphQLSchema , type : GraphQLCompositeType ) : boolean { const unmodifiedType = getRawType ( type ) ; invariant ( unmodifiedType instanceof GraphQLObjectType || unmodifiedType instanceof GraphQLInterfaceType , 'GraphQLSchemaUtils.hasID(): Expected a concrete type or interface, ' + 'got type `%s`.' , type , ) ; const idType = schema . getType ( ID_TYPE ) ; const idField = unmodifiedType . getFields ( ) [ ID ] ; return idField && getRawType ( idField . type ) === idType ; }
Implements duck typing that checks whether a type has an id field of the ID
type. This is approximating what we can hopefully do with the __id proposal
a bit more cleanly.
Implements duck typing that checks whether a type has an id field of the ID type . This is approximating what we can hopefully do with the __id proposal a bit more cleanly .
Returns true if the given type has an ID field.