-
Notifications
You must be signed in to change notification settings - Fork 89
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
How can use SOFA with Conditional Schema? #1357
Comments
You can use Yoga as in the example then add SOFA plugin :) |
Hey, there is no documentation on how to use this plugin with Conditional Schema. Based on the request. |
Maybe I am missing something here. Conditional schema is the configuration for Yoga. You configure the schema as in that section you shared then add the plugin as in the one I sent. |
Ok, you are right, I just create an issue for the wrong repo 😞 It's Yoga's error. I will close the issue. Thanks. |
This is the minimal reproduction, You can check logs. I also create an issue for Yoga. Without a Sofa plugin, it works fine. |
i have a similar problem.: https://the-guild.dev/graphql/yoga-server/docs/features/sofa-api const yoga = createYoga({
landingPage: true,
schema: createSchema({ typeDefs, resolvers }),
plugins: [
useSofa({
basePath: '/api',
swaggerUI: {
endpoint: '/swagger'
},
openAPI: {
info: {
title: 'Bun Server REST API',
version: '1.0.0',
description: 'Bun Server REST API'
}
},
})
]
},) I call rest api on swagger successfully. but when calling on graphql, the following error is reported. Haven't called the server yet {
"errors": [
{
"message": "Failed to fetch",
"extensions": {
"requestBody": {
"query": "query MyQuery {\n getPost(id: 1) {\n content\n title\n id\n }\n}",
"operationName": "MyQuery"
},
"responseDetails": {}
}
}
]
} but when I remove the plugin, graphql works normally const yoga = createYoga({
landingPage: true,
schema: createSchema({ typeDefs, resolvers }),
// plugins: [
// useSofa({
// basePath: '/api',
// swaggerUI: {
// endpoint: '/swagger'
// },
// openAPI: {
// info: {
// title: 'Bun Server REST API',
// version: '1.0.0',
// description: 'Bun Server REST API'
// }
// },
// })
// ]
},) {
"data": {
"getPost": null
}
} i use bun 1.04 import { createSchema, createYoga } from 'graphql-yoga'
import { BunToText } from './utils/text-logs';
import { readFileSync } from 'node:fs'
import { resolvers } from './modules/app.resolvers';
import { useSofa } from '@graphql-yoga/plugin-sofa'
const typeDefs = readFileSync('./schema.graphql', 'utf8')
const yoga = createYoga({
landingPage: true,
schema: createSchema({ typeDefs, resolvers }),
// plugins: [
// useSofa({
// basePath: '/api',
// swaggerUI: {
// endpoint: '/swagger'
// },
// openAPI: {
// info: {
// title: 'Bun Server REST API',
// version: '1.0.0',
// description: 'Bun Server REST API'
// }
// },
// })
// ]
},)
const server = Bun.serve({
fetch: yoga.fetch.bind(yoga),
port: Bun.env.PORT || 8888,
hostname: Bun.env.HOST || 'localhost',
development: Bun.env.NODE_ENV !== 'production' ? true : false
});
console.info(BunToText)
console.info(
`Server is running on ${new URL(
yoga.graphqlEndpoint,
`http://${server.hostname}:${server.port}`
)}`
) link github source: https://github.com/devhoangkien/bun-server-template.git |
Hey, Is there any way to use SOFA with Conditional Schema?
The text was updated successfully, but these errors were encountered: