This filter allows the model generated by the DataLoader to be filtered. Returning anything other than null here will bypass the default model generation for an object.

One example would be WooCommerce Products returning a custom Model for posts of post_type “product”.

apply_filters( 'graphql_dataloader_pre_get_model', null $model, mixed $entry, mixed $key, AbstractDataLoader $loader );


  • $model (null|Model): The filtered model to return. Default null
  • $entry (mixed): The entry loaded from the dataloader to be used to generate a Model
  • $key (mixed): The Key used to identify the loaded entry
  • $loader (AbstractDataLoader): The AbstractDataLoader instance