datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 50 forks source link

Is there a way to combine results from 2 different models in a single query? #182

Closed dante-blitz closed 2 years ago

dante-blitz commented 2 years ago

I'm working on a project that has 2 models: 'News Article' and 'Event'. The project requires a "News a Events" section that lists all News Articles and Events by date.

Rather than combining (and then sorting) the separate results of allDatoCmsEvent and allDatoCMSNewArticle in js I want to know if there is a way to combine the results of both in the graphql query.

I've looked at the Gatsby Node API's, mainly tring to create an abstract scehma type, but so far I have not found anything that works with the dato-cms plugin.

Any help is greatly apprciated.

matjack1 commented 2 years ago

hey @dante-blitz I don't think you can do this directly in the GraphQL call unfortunately. I think you need to do it in your code sorry :(