[IMPLEMENTED] Retrieving a post from graphql without know which schema it belongs to

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [X] Documentation issue or request

Current behavior

Hi Sebastian, I was going through some of the graphql functions and i was wondering whether or not it’s possible to “search and retrieve” an article from different schemas with a general query.
For example: We have various schemas for articles, single content and page content, but I would like to not have to call queryArticleContents, querySingleContents or queryPageContent separately given that X article could be in either of the 3 schemas and I would have to know where it was placed and I have only the ID passed through.

Expected behavior

Minimal reproduction of the problem

Environment

App Name:

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]
7.3

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

The normal REST endpoint has a query to get multiple content items from all schemas by IDs. But not graphql.

if these content items are references from another content item it would work. But I have to add a new resolver for that.

if you need that, you can convert this ticket to feature request.

I have added a new function to graphql:

query ContentsQuery($ids: [String!]!) {
	queryContentsByIds(ids: $ids) {
		... on Content {
			id
		}
		... on Cities {
			data: flatData {
				name
			}
		}
		... on States {
			data: flatData {
				name
			}
		}
	}
}

You have to use unions for that.

To make the life easier there is also a new resolver, which can be used to get the plain data:

query ContentsQuery($ids: [String!]!) {
	queryContentsByIds(ids: $ids) {
		... on Content {
			id,
			data: data__dynamic
		}
	}
}

Hi Sebastian,
this is awesome news. When will this implementation be available?
Thank you very much
Lannie

Just use the dev tag: squidex/squidex:dev-7538

This topic was automatically closed after 2 days. New replies are no longer allowed.