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

Fix WithDescendants union type regression in scaffolding #215

Open
chillu opened this issue Feb 13, 2019 · 5 comments
Open

Fix WithDescendants union type regression in scaffolding #215

chillu opened this issue Feb 13, 2019 · 5 comments

Comments

@chillu
Copy link
Member

chillu commented Feb 13, 2019

The docs say that you get <type>WithDescendants, but you don't. It's unclear when that happend, but it's a regression which versioned-admin and elemental now rely on. They can't just change their query to use descendant based logic, because that would force them to dynamically create those queries (based on the available types in a particular SilverStripe project).

We could fix this through #209 (RFC: Replace "descendant unions" with fields to simplify querying), but that seems like a long time to leave this regression in the module.

This has also come up with devs on the #graphql channel just now

@chillu
Copy link
Member Author

chillu commented Feb 13, 2019

@unclecheese Just to minimise confusion here, could you validate my assumptions here?

@chillu
Copy link
Member Author

chillu commented Feb 17, 2019

Workaround for this in open-sausages@6dcc005

@chillu
Copy link
Member Author

chillu commented Feb 26, 2019

Demo of the current issue in 3.0.1:

graphql.yml

SilverStripe\Control\Director:
  rules:
    'graphql': '%$SilverStripe\GraphQL\Controller.default'
SilverStripe\GraphQL\Manager:
  schemas:
    default:
      scaffolding:
        types:
          Page:
            fields: '*'
            operations:
                read: true
           SilverStripe\ErrorPage\ErrorPage:
             fields: [ErrorCode]
query readPages {
  readPages {
    edges {
      node {
       	Title
        ErrorCode
      }
    }
  }
}

Response

{
  "data": null,
  "errors": [
    {
      "message": "Cannot query field \"ErrorCode\" on type \"Page\".",
      "locations": [
        {
          "line": 6,
          "column": 9
        }
      ]
    }
  ]
}

@chillu
Copy link
Member Author

chillu commented Feb 26, 2019

This doesn't work either

graphql.yml

SilverStripe\Control\Director:
  rules:
    'graphql': '%$SilverStripe\GraphQL\Controller.default'
SilverStripe\GraphQL\Manager:
  schemas:
    default:
      scaffolding:
        types:
          Page:
            fields: [Title,ErrorCode]
            operations:
              read: true
          SilverStripe\ErrorPage\ErrorPage:
            fields: [ErrorCode]

Response

{
  "errors": [
    {
      "message": "Invalid field \"ErrorCode\" on Page",
      "code": 0,
      "file": 

@TheBnl
Copy link

TheBnl commented May 8, 2020

I was questioning wat the current way of working with descendants is, or if there is an alternative to <type>WithDescendants for version 3.2.3? Those types don't show up in my introspection.

Using the union method as described in the readme section results in the following error: Fragment cannot be spread here as objects of type \"Block\" can never be of type \"VideoBlock\".

I'm asking here because i'm not quite sure what to do, and if this is still a work in progress should the readme be updated stating that it is a WIP feature?

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

3 participants