Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] Using the bulk loader breaks page polymorphism #468

Open
bummzack opened this issue May 24, 2022 · 3 comments
Open

[v4] Using the bulk loader breaks page polymorphism #468

bummzack opened this issue May 24, 2022 · 3 comments

Comments

@bummzack
Copy link
Contributor

Let's say that I have a Page and a CustomPage class:

Page:
  fields:
    id: true
    title: true

My\Project\CustomPage:
  fields:
    customField: true

When I query

query {
  readPages {
    nodes {
      title
      __typename
    }
  }
}

I get the following result:

{
  "data": {
    "readPages": {
      "nodes": [
        {
          "title": "Regular page",
          "__typename": "Page"
        },
        {
          "title": "Special Page",
          "__typename": "CustomPage"
        },
        …
      ]
    }
  }
}

The returned __typename is correct, and I can also query fields of CustomPage by using the ... on CustomPage syntax.

As soon as I use the bulk-load feature (eg. by creating a _graphql/bulkLoad.yml config for some extensions), I lose polymorphism and all pages get "Page" as their __typename. Queries with fragments also fail, with an error like:

"Fragment cannot be spread here as objects of type "Page" can never be of type "CustomPage"."

@bummzack
Copy link
Contributor Author

bummzack commented May 24, 2022

I've created a vanilla install to test/reproduce this behavior and was unable to reproduce. Will close until I find the real issue.

Update: Can reproduce, will post example repo soon

@bummzack bummzack reopened this May 24, 2022
@bummzack
Copy link
Contributor Author

Code to reproduce can be found here: https://github.com/bummzack/graphql-issue-468

@bummzack
Copy link
Contributor Author

I have found that the issue also manifests, depending on the order in which models are declared.
One example where I observed this behaviour:

# _models.yml

My\Project\CustomElementalElement:
  fields:
    relatedPages: true # This returns a DataList of related Pages (CustomPage type)
    
Page:
  fields:
    title: true

My\Project\CustomPage:
  fields:
    customField: true

Declaring the My\Project\CustomElementalElement after the My\Project\CustomPage resolves the issue and I can query CustomPage again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants