-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQL and Scaffolding does not support Prisma Bytes data type #5841
Comments
So reading this issue more its a scalar https://www.graphql-scalars.dev/docs/scalars/byte 'bytes' I have no idea if this works
|
we apply
|
Now to fix it Ok looking at old issue we need to parse the 'value' in a scenario.test.js? Well good news is that Nexus-Prisma has already implemented a bytes scalar support graphql-nexus/nexus-prisma#68 from the GraphQL Scalars Library See code here Is there a way to parse Binary? nodeJS Buffers and blob.arrayBuffer() Ok so 'Byte' Type Scalar for Graphql The Byte scalar type represents byte value as specified by NodeJS Buffer type So a byte value is basically a integer between 0 and 255
What the hell is a buffer in JS?
So Graphql scenarioFieldValue will generate a test of a buffer by passing in random bytes to type check Graphql inside 'The So we wrote our own form of Byte using the GraphQL Scalar library in
We use expect(typeof value).tBe('Buffer') because if you look in line 11 of https://github.com/Urigo/graphql-scalars/blob/aeb8aebc9738d533e0cac4cf6ddbad7d1555814e/src/scalars/Byte.ts
|
Recommend Longterm solutions Graphql and Redwood cannot either cover all custom Scalar types like bytes. However project maintained by The Guild has good Library called GraphQL Scalars that covers near most use cases We import this new library called GraphQL Scalars we install this and import the Type Scalars inside of GraphSQL Scalars Library because they have validation code already and covers go use cases For this problem with Bytes they have
Oh it comes with Apollo I am dumb https://www.apollographql.com/docs/apollo-server/schema/custom-scalars/ |
Ah
This was the tricky part that I hard problems with when trying to implement Bytes in the scenarios and tests. Maybe that will work. |
Well am stuck basically its not passing a "Buffer" type I am too inexperience can we PR this we need collaboration |
Ok When I test typeof BufferObject it appears as a 'object' because in JS everything is Object but how do you check that a object is buffer, even though we used GraphQLByte.parseValue(value) and jest is expecting a Buffer we have to check with a different test code
output
object
we edit scenario.test.js |
Ok its passible it worked @dthyresson however new bug and I cannot run yarn e2e I am on Windows
|
Hi @Gresliebear and thanks for the progress? I was planning to work on this issue the week and maybe we can collaborate using the work you've done as I bet it is close. Could you submit a Draft PR with your work in progress and I can review and see what else might be needed? Thanks! |
@dthyresson yes give me 30 minutes because I don't know how to PR quickly this is my 2nd time so my apologizes, Where I left off I made changes and then Then did Recommended feature scaffold should autogenerated a drag and dropbox or click here to upload files button |
@dthyresson |
Re-assigned based on review of PR #5874 |
Completing this #5874 PR can be a label:hackoberfest item |
Hi, I found the same error (not sure if this is related) when trying to generate SDL for UserCredentials when using AuthDB with WebAuthn on Windows (I cannot test this on other systems). There should be either note NOT to use WebAuthn with Windows or it needs a fix as it's preventing the feature from working. Unless it is possible to change type from Bytes to something else. model UserCredential {
id String @id
user User @relation(fields: [userId], references: [id])
userId String
publicKey Bytes
transports String?
counter BigInt
} |
I also posted this comment over here, but you shouldn't create an SDL file for |
We can't create a scaffold for a table with a relation with User if we don't create the sdl for UserCredential, what I understand with scaffold command is that we have to create all the relations, User have a relation with UserCredential, my table Product have a relation with User ... here the message when I want to go to /products page
|
You shouldn't create a scaffold for But you're saying that once you create the That error sounds like the API server stopped running, can you check back further in the console output and see what the error was that crashed it? |
As I'm thinking about this more, is it that the Unfortunately there's no easy way to exclude that relationship from the SDL generating logic at this point. We're talking about creating an allow/block list of attribute names, and could include |
I can confirm I've wiped out the db, migrate without UserCredential and now I can scaffold my Product table who have a relation with User who don't have a relation with UserCredential |
I'll try this |
Looks like we give a warning message now, telling you that there's a relationship defined in an SDL but no other SDL file that actually defines the type: So if you're seeing an error like that, you should just be able to remove any reference to |
The errors when I do nothing just create sdl for relations with my Product table
The error when I remove the relation with UserCredential in |
If I comment also |
Huh...not sure why you'd need to comment that one out, although it's a good practice to do so (that's another field that shouldn't be accessed via GraphQL). You should really comment out Sometimes it takes a couple tries for the API server to realize something has changed and reload itself, maybe commenting out |
No it's a wrong refresh, it' work witout commenting ! sorry but yeah we need to comment |
Okay sounds good, I'm updating the documentation now! |
PR merged here: #6672 |
My database is postgres server.
I made model Asset following the tutorial in schema.prisma
I went to generate my scaffold
Yarn rw g scaffold asset
then my error
The text was updated successfully, but these errors were encountered: