apollo-server

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

佐手、 提交于 2021-01-04 03:22:52
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

Prisma 2 query to return records only that are associated with ALL of the provided tag IDs

我的梦境 提交于 2021-01-04 03:22:10
问题 I have tables Principles and Tags. And there is a many-to-many relation between them (joined implicitly). Without using prisma.raw , how can I run the following query? SELECT p.id, p.title, p.description, p.createdAt, p.modifiedAt FROM principle p WHERE EXISTS (SELECT NULL FROM _PrincipleToTag pt WHERE pt.B IN (${tagIds.join(',')}) AND pt.A = p.id GROUP BY pt.A HAVING COUNT(DISTINCT pt.B) = ${tagIds.length}) How can I update this Prisma 2 query such that the principles returned are only

disable graphiql on production

和自甴很熟 提交于 2020-12-30 08:14:43
问题 How can I disable graphiql on production but still able to access it on development? With express-graphql we can do something like app.use('/graphql', graphqlHTTP({ schema: MySessionAwareGraphQLSchema, graphiql: process.env.NODE_ENV === 'development', })); With apollo server, my setup is import {graphqlExpress, graphiqlExpress} from 'graphql-server-express' const app = new Express() app .all('/graphql', bodyParser.json()) .all('/graphql', graphqlExpress({ schema ) .all('/graphiql',

Graphql-Access arguments in child resolvers

这一生的挚爱 提交于 2020-08-22 04:19:06
问题 I am using apollo-server and apollo-graphql-tools and I have following schema type TotalVehicleResponse { totalCars: Int totalTrucks: Int } type RootQuery { getTotalVehicals(color: String): TotalVehicleResponse } schema { query: RootQuery } and Resolver functions are like this { RootQuery: { getTotalVehicals: async (root, args, context) => { // args = {color: 'something'} return {}; }, TotalVehicleResponse: { totalCars: async (root, args, conext) => { // args is empty({}) here ......... .....

NestJS with Apollo DataSource

核能气质少年 提交于 2020-08-10 18:50:07
问题 I have been trying to re-create the Apollo tutorial with NestJS. But when I try using apollo-datasource-rest with NestJS, it fails when fetching data from the external data source with the following error: [Nest] 29974 - 07/14/2020, 9:33:20 PM [ExceptionsHandler] Cannot read property 'fetch' of undefined +125971ms TypeError: Cannot read property 'fetch' of undefined It seems as if the data source class in not being injected properly in the resolver, but I can't figure out why? // The data

Get model from context vs Import - apollo server express & mongoose

只谈情不闲聊 提交于 2020-07-23 06:43:26
问题 I am wondering if there is a difference, or what is best practice in an apollo-server to query mongodb via mongoose Get model from context: import User from './User' const apolloServer = new ApolloServer({ typeDefs, resolvers, context: ({ req, res }) => ({ req, res, User, }), getUser(parent, args, context, info) { return context.User.findOne({ _id: args.id}) }, VS import User from './User' getUser(parent, args, context, info) { return User.findOne({ _id: args.id}) }, 回答1: Inject dependencies