6 I have a problem in Prisma data modeling where I have to constrain that a user can submit only one review for a product. I have following design for the non-constrained situation. Should Customer and Product be combined into a primary key in ProductReview model, or should this constraint be imposed at the application […]
1 My App.js const mongoose = require(‘mongoose’); const dotenv = require(‘dotenv’); const { ApolloServer } = require(‘apollo-server’); const { startStandaloneServer } = require(‘@apollo/server/standalone’); const typeDefs = require(‘./apolloGraphql/schema’); const resolvers = require(‘./apolloGraphql/resolvers’); const auth = require(‘./Middleware/Auth’); dotenv.config({ path: ‘./config/.env’ }); const server = new ApolloServer({ typeDefs, resolvers, }); mongoose .connect(process.env.MONGOURI) .then((result) => { return server.listen(process.env.PORT, (req, […]
0 I’ve successfully created a Cypress test that creates a new token and user object. The problem is that, since I’ve hard coded the arguments accepted by the addUser mutation, the test only runs once. On a second run, the DB returns an error stating that the user already exists. I have a deleteUser mutation […]
0 We’re using NodeJS (typescript) and GraphQL for our backend. Therefore we rely heavily on dataloaders, and we get more and more field resolvers that needs to be resolved on something other than IDs. An example is a field resolver on our User object, called "follows_me". In this case we need to make a lookup […]
5 Problem Description I have a chat component in angular that gets messages from the backend via a graphql query. On the same query, I subscribe to updates when a new message is added via a graphql mutation. The messages subscription is coded as a method of the chat component so that I can invoke […]
8 import { isEmail, isEmpty, isPhoneNumber, Length } from "class-validator" import { Field, InputType } from "type-graphql"; @InputType() export class RegisterInput { @Field() @Length(2, 15, { message: "Username Must Be At Least 2 characters" }) username?: string; @Field() @isEmail() email?: string; @Field() @Length(1, 20) @isPhoneNumber() phoneNumber?: string; @isEmpty() password?: string } The thing is @isEmail() […]
9 I don’t understand why in foobar below I need to specify std::vector<int>{} whereas in foobar2 I do not: #include <iostream> #include <memory> #include <vector> #include <tuple> std::tuple<std::unique_ptr<int>, std::vector<int>> foobar() { std::unique_ptr<int> test = std::make_unique<int>(42); return { std::move(test), {} }; // <= this is a syntax error // return { std::move(test), std::vector<int>{} } // <= […]
0 Here’s my schema: type Post @model { createdAt: AWSDateTime! hash: String! version: Int @default(value: "0") @index(name: "byVersion", sortKeyFields: ["createdAt"]) } Here’s the generated query that AWS Amplify generates: export const postsByVersionAndCreatedAt = /* GraphQL */ ` query postsByVersionAndCreatedAt( $version: Int! $createdAt: ModelStringKeyConditionInput $sortDirection: ModelSortDirection $filter: ModelPiecePostFilterInput $limit: Int $nextToken: String ) { postsByVersionAndCreatedAt( version: […]
9 I don’t have any UI framework. Just a simple Nodejs script where I need to query a GraphQL. Codes: const ApolloClient = require(‘apollo-client’) const client = new ApolloClient() Error message: TypeError: ApolloClient is not a constructor Package.json: { … “dependencies”: { “apollo-client”: “^2.4.13”, “graphql”: “^14.1.1”, “graphql-tag”: “^2.10.1” }, } Node: v8.9.4 I googled a […]
0 I’m rewriting a script to upload large batches of images to Shopify using the GraphQL API. I keep running into two issues, the first is images that upload successfully do not process properly. The second issue is I hit the rate limit and the script breaks out of the loop despite having exponential rate […]