可空的 order 字段中有一个非空 total,但它解析为 null。result.data 包含什么?
JavaScript
const { buildSchema, graphql } = require("graphql");
const schema = buildSchema(`
type Order { id: ID!, total: Int! }
type Query { service: String!, order: Order }
`);
const result = await graphql({
schema,
source: `{ service order { id total } }`,
rootValue: { service: "shop", order: { id: "o1", total: null } },
});
console.log(JSON.stringify(result.data));