我想对包含对象数组的 jsonb/documents 进行更复杂的查询。有没有人推荐 Node 的库?我正在使用pg,但我想做更高级的查询,例如选择文档,其中文档具有一个数组,其中包含具有特定键/值的对象。如果没有任何库可以做到这一点,有谁知道我如何在 psql 中使用 json 函数/等来做到这一点?或者向我指出一本可以学习这种高级查询的书籍/资源?
更新:apollo已更新代码和文档,因此问题现在无关紧要
预期结果
使用https://github.com/apollographql/apollo-tutorial-kit中的以下代码段启动apollo-server-express .
import express from 'express';
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express';
import bodyParser from 'body-parser';
import schema from './data/schema';
const GRAPHQL_PORT = 3000;
const graphQLServer = express();
graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
graphQLServer.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
graphQLServer.listen(GRAPHQL_PORT, () => console.log(`GraphiQL is now running on http://localhost:${GRAPHQL_PORT}/graphiql`));
Run Code Online (Sandbox Code Playgroud)
实际结果:
在apollo-server-express的任何实现中,使用docs,使用https://github.com/apollographql/apollo-tutorial-kit等.我一遍又一遍地收到以下堆栈跟踪:
Error: Must provide document
at invariant (~/node_modules/graphql/jsutils/invariant.js:18:11)
at Object.validate (~/node_modules/graphql/validation/validate.js:58:34)
at doRunQuery (~/node_modules/apollo-server-core/dist/runQuery.js:80:38)
at ~/node_modules/apollo-server-core/dist/runQuery.js:20:54
at <anonymous>
Run Code Online (Sandbox Code Playgroud)
如何重现问题:
git clone https://github.com/apollographql/apollo-tutorial-kit.git
cd apollo-tutorial-kit
yarn/npm …Run Code Online (Sandbox Code Playgroud)