dotansimha / graphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
https://the-guild.dev/graphql/yoga-server
MIT License
8.23k stars 566 forks source link

Enabling @graphql-yoga/plugin-sofa plugin breaks GraphQL operations #3112

Open rhino88 opened 11 months ago

rhino88 commented 11 months ago

Describe the bug

After adding the sofa plugin according to the docs (removed title/version to avoid typescript issue) graphql operations are no longer working.

const yoga = createYoga({
  graphiql: {
    defaultQuery,
  },
  schema,
  plugins: [
    useSofa({
      basePath: "/rest",
      swaggerUI: {
        endpoint: "/swagger",
      },
    }),
  ],
});

Before adding useSofa as a plugin any GraphQL query from the graphiql interface is executed as expected:

image

After adding useSofa as a plugin any GraphQL query from the graphiql interface results in an error:

image

Your Example Website or App

https://codesandbox.io/p/devbox/fervent-cray-67rsd5?file=%2Fsrc%2Fmain.ts%3A22%2C1-35%2C4

Steps to Reproduce the Bug or Issue

  1. Go to reproduction 2 Execute any valid GraphQL Query

Expected behavior

Expecting the swagger UI to render at the appropriate route, and for GraphQL operations to continue functioning as normal.

Screenshots or Videos

No response

Platform

Additional context

No response

EmrysMyrddin commented 10 months ago

Hi @rhino88 and thank you for the report

Sorry but I'm not adding a lot here but just labeling it according to our new Contribution Guide and issue flow.

It seems already got into stage 1 thanks to your reproduction! Thank you for that!

Now in order to advance to stage 2 we'll need a failing test, would be great if someone could help progress the issues through the stages.

Thank you and sorry that this comment is not a complete solution (yet).

Hurled4505 commented 10 months ago

@rhino88 you tried to access the swagger using the wrong url. Since you defined a basePath, the swagger can be found under localhost:4000/rest/swagger instead of just localhost:4000/swagger. But why the graphql query is not working I don't really know.

rhino88 commented 10 months ago

Thanks @Hurled4505 , I updated the issue to clarify the details.