Skip to content

urql not parsing response if payload is present in the first element (apollo federation) #3763

@SkArchon

Description

@SkArchon

Describe the bug

While testing our backend with urql, we noticed that the urql code seemed to work only if the first element did not contain payload. (see attached screenshot). This is related to subscriptions when using multipart.

Image

It seems that after result is not null, payload can be used as the root element

Image

Related To: #3499

Reproduction client

const { Client, cacheExchange, fetchExchange } = require('@urql/core');

const client = new Client({
  url: 'http://localhost:3002/graphql',
  exchanges: [
    cacheExchange, fetchExchange
  ],
  fetchSubscriptions: true,
  fetchOptions: () => {
    return {
      headers: {
        accept: 'multipart/mixed;boundary="graphql"'
      },
    };
  },
});

async function query() {
  const QUERY = `
     subscription Test {
    countEmp2(max: 5, intervalMilliseconds: 1000)
  }
  `;
  const { unsubscribe } = client.subscription(QUERY).subscribe(result => {
    result.data
    console.log(result.data); // { data: ... }
  });
}

query();

Reproduction

Reproduction Is In Description, don't have a backend available to share atm

Urql version

@urql/core, 5.1.1

Validations

  • I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
  • Read the docs.
  • Follow our Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions