-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Version Information
Server Version:
CLI Version (for CLI related issue):
Environment
OSS, Docker
What is the current behaviour?
When querying a remote relationship with an alias, the __typename field from the remote schema loses its configured prefix, resulting in an inconsistency between type names returned by direct remote schema queries and those accessed through relationships.
This causes runtime and type generation mismatches, since GraphQL Code Generator correctly applies the prefix to generated types, but the runtime result (when aliasing is used) does not include it.
What is the expected behaviour?
The __typename field should always include the configured prefix (e.g., cf_Entry) regardless of whether the remote relationship is queried directly, or via an alias.
How to reproduce the issue?
- Add Contentful (or any remote schema) to Hasura with a configured prefix, e.g.,
cf_. - Create a table in Hasura, e.g.,
article. - Add a remote relationship from
articleto a Contentful type, e.g.,contentful_entry→cf_entry. - Run the following queries:
✅ Works — direct remote schema query
Query:
query {
cf_entryCollection(limit: 1) {
items {
__typename
sys { id }
}
}
}Result:
{
"data": {
"cf_entryCollection": {
"items": [
{
"__typename": "cf_Entry",
"sys": { "id": "123" }
}
]
}
}
}✅ Works — remote relationship without alias
Query:
query {
article {
id
contentful_entry {
__typename
sys { id }
}
}
}Result:
{
"data": {
"article": [
{
"id": 1,
"contentful_entry": {
"__typename": "cf_Entry",
"sys": { "id": "123" }
}
}
]
}
}✅ Works — direct remote schema query with alias
Query:
query {
cfEntries: cf_entryCollection(limit: 1) {
items {
__typename
sys { id }
}
}
}Result:
{
"data": {
"cfEntries": {
"items": [
{
"__typename": "cf_Entry",
"sys": { "id": "123" }
}
]
}
}
}❌ Fails — remote relationship with alias
Query:
query {
article {
id
contentfulEntry: contentful_entry {
__typename
sys { id }
}
}
}Result:
{
"data": {
"article": [
{
"id": 1,
"contentfulEntry": {
"__typename": "Entry", // ❌ missing prefix
"sys": { "id": "123" }
}
}
]
}
}Any possible solutions/workarounds you're aware of?
For now I've given up on alias in gql and map them manually.
Keywords
Remote, remote schema, remote relationship, __typename, aliases