Jeff
06/10/2022, 2:33 AMSam Lambert
06/10/2022, 4:08 AMMichael Roberts
06/10/2022, 8:22 AMtype AccountType @default(DEFAULT)
does anyone know how this could work with zod?FUTC
06/10/2022, 10:11 AMtest
I only find test org
from my db but not the other entries with the name test2 org
and test3 org
Edit: just found the contains
operator which seems to work. What is the difference between the full text search and something like the contains operator when searching a column?Michael Roberts
06/10/2022, 10:28 AMMichael Roberts
06/10/2022, 10:28 AMnode_modules/.prisma/client/index.d.ts(6,26): error TS2307: Cannot find module '@prisma/client/runtime/proxy' or its corresponding type declarations.
Charles Gaudreau Jackson
06/10/2022, 3:49 PMJose Maria CL
06/10/2022, 7:08 PMGezim
06/10/2022, 7:42 PMmodel ShopifyOfflineStoreSession {
pk String @id(map: "PK_d371917bab72a48d6cce7880fc5") @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
id String @unique(map: "UQ_91ede9e23efbd7ee27b37bdd9ba") @db.VarChar
store Store? @relation(fields: [pk], references: [shopifyOfflineSessionPk], onDelete: Cascade, onUpdate: Cascade, map: "FK_901a837fbbf20119aded3682f90")
@@map("shopify_store_session")
}
model Store {
id Int @id(map: "PK_f3172007d4de5ae8e7692759d79") @default(autoincrement())
shopifyOfflineSessionPk String? @unique(map: "UQ_901a837fbbf20119aded3682f90") @db.Uuid
shopifyOfflineSession ShopifyOfflineStoreSession?
@@map("store")
}
This query fails:
await this.prisma.shopifyOfflineStoreSession.create({
data: {
...session,
store: { connect: { id: store.id } },
},
});
Error:
db | 2022-06-10 16:41:02.035 UTC [15541] ERROR: null value in column "pk" violates not-null constraint
db | 2022-06-10 16:41:02.035 UTC [15541] DETAIL: Failing row contains (null, <http://offline_subbooks2.myshopify.com|offline_subbooks2.myshopify.com>, 2022-06-10 16:41:02.033, 2022-06-10 16:41:02.033, null, <http://subbooks2.myshopify.com|subbooks2.myshopify.com>, <some long number here>, f, null, null, null).
db | 2022-06-10 16:41:02.035 UTC [15541] STATEMENT: INSERT INTO "public"."shopify_store_session" ("pk","id","createdAt","updatedAt","shop","state","isOnline") VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING "public"."shopify_store_session"."pk"
api | Issue saving Shopify offline token. Err: PrismaClientKnownRequestError:
api | Invalid `this.prisma.shopifyOfflineStoreSession.create()` invocation in
api | /usr/src/api/src/store/store.service.ts:576:52
api |
api | 573 data: session,
api | 574 });
api | 575 } else {
api | → 576 await this.prisma.shopifyOfflineStoreSession.create(
api | Null constraint violation on the fields: (`pk`)
api | at cb (/usr/src/api/node_modules/@prisma/client/runtime/index.js:38683:17) {
api | code: 'P2011',
api | clientVersion: '3.6.0',
api | meta: { constraint: [ 'pk' ] }
api | }
api | query: DELETE FROM "store" WHERE "id" IN ($1) -- PARAMETERS: [18]
I don’t understand why prisma is setting pk
on shopifyOfflineStoreSession
to null. Can someone help me understand what’s causing this error?Morritz
06/10/2022, 8:02 PMMichael Roberts
06/11/2022, 9:47 AMHalvor
06/11/2022, 12:52 PMHalvor
06/11/2022, 1:06 PMHalvor
06/11/2022, 1:12 PMconst result = await prisma.stat.count({
by: ["userId"]
});
Halvor
06/11/2022, 1:12 PMPhilippe Sabourin
06/11/2022, 1:46 PMprisma db push
and prisma studio
work fine, but within the app, it gives me this error:
prisma:info Starting a mssql pool with 13 connections.
prisma:info Performing a TLS handshake
prisma:warn Trusting the server certificate without validation.
prisma:info TLS handshake successful
prisma:error Login failed for user 'giqconnect'.
The same URL for all 3, also using the same URL in another app and it works fine there.Philippe Sabourin
06/11/2022, 2:11 PMAmresh Prasad Sinha
06/11/2022, 4:03 PMfindUnique
.
Here are the logs: https://pastebin.com/nXeCa109
I can't figure out why its not working 😕Berian Chaiwa
06/11/2022, 7:01 PMgraphql-shield
to help me with this basic setup? I tried the below rule/permission setup but it is not being invoked no matter what:
rule.ts
import { rule, and, or, not } from "graphql-shield";
import { GraphQLContext } from "..";
const isValidInvitation = rule()(
async (parent, args, ctx: GraphQLContext, info) => {
console.log("parent", parent);
console.log("args", args);
console.log("ctx", ctx);
return false;
}
);
export default { isValidInvitation };
permissions/index.ts
import { shield } from "graphql-shield";
import rules from "./rules";
const permissions = shield({
Mutation: {
createInvitedUser: rules.isValidInvitation,
},
});
export default permissions;
src/index.ts
import { applyMiddleware } from "graphql-middleware";
import { schema } from "./api/schema";
import permissions from "./permisions";
const secureSchema = applyMiddleware(schema, permissions);
...
startApolloServer(secureSchema, prisma);
My schema is pretty big and I want to test protecting a type/resolver at a time. Any ideas? Thanks.Nathaniel Babalola
06/11/2022, 7:51 PMAurora
06/12/2022, 4:38 AMAurora
06/12/2022, 5:10 AMTheLegend29
06/12/2022, 3:22 PMGelo
06/12/2022, 4:33 PMkyler
06/13/2022, 1:58 AMBerian Chaiwa
06/13/2022, 10:01 AMRejectOnNotFound
is configured? I am trying to catch it like below but it is always escaping me:
catch (error) {
if (error instanceof PrismaClientKnownRequestError) {
throw new AuthenticationError(error.name);
} else if (
error instanceof
(PrismaClientUnknownRequestError || PrismaClientValidationError)
) {
throw new AuthenticationError(error.message);
}
// Otherwise send to Sentry so we can debug
console.log("Authentication Error", error);
throw new ApolloError("INTERNAL SERVER ERROR", "INTERNAL_SERVER_ERROR");
}
Pieter
06/13/2022, 11:13 AMOliver St.
06/13/2022, 11:18 AMERR_PNPM_BAD_PACKAGE_JSON ****/pnpm-workspace-template/libs/prisma/node_modules/@prisma/client/package.json: Invalid name: “.prisma/client”
So pnpm doesn’t allow package names starting with a dot .
Does a fix exist or is this a new issue?Brendan Allan
06/13/2022, 12:51 PM&& opt
should be && !opt
. The potential mistake is query-engine/core/src/response_ir/internal.rs
line 267Berian Chaiwa
06/13/2022, 2:07 PMexpress-jwt
with Express Apollo Server
? I can't figure out why jwt verification errors are not being thrown back to Apollo. I see express-jwt
logging the error but never received in Apollo Studio Explorer. I am using it like this but I can't figure out how to blend it into the Apollo/GraphQL error handling loop. Should I apply it as schema middleware or just as a regular express request middleware?:
export function createContext(
req: JWTRequest,
prismaClient: PrismaClient
): GraphQLContext {
return {
req,
prisma: prismaClient,
};
}
async function startApolloServer(
gqlSchema: GraphQLSchema,
prismaClient: PrismaClient
) {
dotenv.config();
const app = express();
// here is how I am using it but when token is invalid it prevents request from proceeding(which is okay) but the errors are not sent back to Apollo Studio Explorer like any other errors raised by resolvers.
app.use(
expressjwt({
secret: process.env.JWT_SECRET!,
algorithms: ["HS256"],
credentialsRequired: false,
})
);
// 1. Http Server
const httpServer = http.createServer(app);
// 2. Websocket Server
const wsServer = new WebSocketServer({
server: httpServer,
path: "/",
});
const wsServerCleanup = useServer({ schema: gqlSchema }, wsServer);
// 3. Apollo Server
const server = new ApolloServer({
schema,
context: ({ req }) => {
return createContext(req, prismaClient);
},
csrfPrevention: true,
plugins: [
// Proper shutdown for the HTTP server.
ApolloServerPluginDrainHttpServer({ httpServer }),
// Proper shutdown for the websocket server
{
async serverWillStart() {
return {
async drainServer() {
await wsServerCleanup.dispose();
},
};
},
},
],
});
await server.start();
server.applyMiddleware({
app,
});
await new Promise<any>((resolve: any) =>
httpServer.listen({ port: process.env.PORT }, resolve)
);
console.log(`🚀 Server ready at <http://localhost:4000>${server.graphqlPath}`);
}