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

[relay-compiler 13] The root of subscription must be a simple selection #3703

Closed
radoslavkarlik opened this issue Dec 24, 2021 · 8 comments
Closed
Assignees
Labels
bug fixready rust Related to the compiler written in Rust

Comments

@radoslavkarlik
Copy link

Reporting issues with Relay

Given schema

type Subscription {
    changed: String!
}

And App.tsx

graphql`
  subscription App_Subscription {
      changed
  }
`;

I get this error: [ERROR] ✖︎ The root of subscription 'App_Subscription' must be a simple selection.

It seems like the subscription result needs to be an object. However, returning simple scalars worked in older versions. Is this a breaking change/intended way to use subscriptions?

@kassens
Copy link
Member

kassens commented Dec 28, 2021

This is an accidental regression. We need this for an internal purpose (I think logging the subscription name or something), but the validation shouldn't happen in OSS code. We'll move this to private extensions.

@kassens kassens self-assigned this Dec 28, 2021
@kassens kassens added the bug label Dec 28, 2021
@alunyov alunyov assigned alunyov and unassigned kassens Dec 28, 2021
facebook-github-bot pushed a commit that referenced this issue Dec 29, 2021
Summary:
Fix for #3703

- These two transforms are fb-specific, they are used when `fb_only` feature is enabled (and this is ON for fb-specific build)
- OSS `relay-compiler` doesn't have this feature

Reviewed By: kassens

Differential Revision: D33341463

fbshipit-source-id: 3d18c70ed5ed40943e1cb2c7c52d62cd715e7edb
@alunyov
Copy link
Contributor

alunyov commented Dec 29, 2021

This should be fixed with relay-compiler@main.

@alunyov alunyov closed this as completed Dec 29, 2021
@artola
Copy link
Contributor

artola commented Jan 9, 2022

@alunyov This issue was closed, but it remains for me. It is not working with newest v13 neither relay-compiler@master.
@radoslavk is it working for you?

@alunyov
Copy link
Contributor

alunyov commented Jan 10, 2022

Hey @artola can you provide more details here? Are you seeing the same error message?

@artola
Copy link
Contributor

artola commented Jan 10, 2022

@alunyov I confirm the same error reported above.

[ERROR] ✖︎ The root of subscription 'demo4Subscription' must be a simple selection.

  pages/demo4.js:2:22
    1 │ 
    2 │         subscription demo4Subscription($from: Int!) {
      │                      ^^^^^^^^^^^^^^^^^
    3 │           countdown(from: $from)

[ERROR] Compilation failed.

Same result for:

This produces the error:

type Subscription {
  countdown(from: Int!): Int
}
graphql`
        subscription demo4Subscription($from: Int!) {
          countdown(from: $from)
        }
      `

While this works:

type Countdown {
  current: Int!
}

type Subscription {
  countdown(from: Int!): Countdown
}
graphql`
        subscription demo4Subscription($from: Int!) {
          countdown(from: $from) {
            current
          }
        }
      `

@alunyov
Copy link
Contributor

alunyov commented Jan 10, 2022

Hmm, this is strange. Let me reopen this to double-check.

@alunyov alunyov reopened this Jan 10, 2022
@alunyov alunyov added the rust Related to the compiler written in Rust label Jan 11, 2022
@alunyov
Copy link
Contributor

alunyov commented Jan 11, 2022

@artola can you check with this version: 97a0e95

it should be available on NPM as relay-compiler@main

@artola
Copy link
Contributor

artola commented Jan 11, 2022

@artola can you check with this version: 97a0e95

it should be available on NPM as relay-compiler@main

@alunyov IT WORKS!!! ... now it is possible to return some scalar as in the examples above. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixready rust Related to the compiler written in Rust
Projects
None yet
Development

No branches or pull requests

4 participants