所以我有以下路线:/creator/item
和 /creator/item/price
。两条路由的模式都有一个名为 updateOne
的突变。但是,当我调用 /creator/item/price
的路由时,它会匹配 /creator/item
。
这是故意的吗?有解决方法还是我必须为其创建一个完全唯一的路径名?
最佳答案
看起来定义的顺序很重要。
之前:
// - item
const item_schema =
require("./graphql/creator/items")
app.use(
"/creator/item",
graphqlHTTP({
schema:
item_schema,
graphiql:
env !== "production",
formatError
})
)
const item_price_schema =
require("./graphql/creator/item/prices.js")
app.use(
// "/creator/updateOne/price",
"/creator/item/price",
graphqlHTTP({
schema:
item_price_schema,
graphiql:
env !== "production",
formatError
})
)
之后:
const item_price_schema =
require("./graphql/creator/item/prices.js")
app.use(
// "/creator/updateOne/price",
"/creator/item/price",
graphqlHTTP({
schema:
item_price_schema,
graphiql:
env !== "production",
formatError
})
)
// - item
const item_schema =
require("./graphql/creator/items")
app.use(
"/creator/item",
graphqlHTTP({
schema:
item_schema,
graphiql:
env !== "production",
formatError
})
)
关于javascript - express-graphql - 匹配父路由的子路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54902042/