Comments (7)
Thanks @StephanDecker ! Using v1.0.1, with the below Prisma model:
model Phase {
id String @id @default(uuid())
name String @unique
}
The GraphQL output I get is:
input PhaseCreateInput {
id: String
name: String!
}
Which is expected to both allow you to create with or without specifying id
.
What version of Prisma Client are you using? (it should display when running npx prisma generate
)
from prisma-appsync.
Yes, depending on the field definition (e.g. autoincrement
or uuid
) it should create the record with or without specifying id.
In my example it should be:
input PhaseCreateInput {
name: String!
}
That has been already been implemented in a nice way before, see this commit:
bc7320d
Or this code here:
prisma-appsync/packages/generator/src/compiler.ts
Lines 683 to 691 in bc7320d
But I don't know where to put it now (after the refactoring) ;-)
Version details:
Prisma Client (v5.7.1)
Prisma-AppSync (1.0.1)
from prisma-appsync.
Hey @StephanDecker, not having id
entirely in the output was a mistake that's been fixed as part of the v1.0.0 release.
However, you should be able to create a record with or without specifying id
.
On my end, the generated GraphQL output is the correct one:
input PhaseCreateInput {
id: String
name: String!
}
The above allows you to either specify or omit id
entirely.
Could you please double-check that the output on your end is id: String!
and not id: String
as in my example above?
from prisma-appsync.
Sorry, you are completely right. I tried to simplify the problem which is different and didn't work. Unfortunately it's more complicated.
Let's say you have these models:
model ExampleTable {
id String @id @default(uuid())
refTable RefTable[]
}
model RefTable {
id String @id @default(uuid())
downstreamRefTable DownstreamRefTable @relation(fields: [downstreamRefTableId], references: [id])
downstreamRefTableId String
exampleTable ExampleTable @relation(fields: [exampleTableId], references: [id])
exampleTableId String
}
model DownstreamRefTable {
id String @id @default(uuid())
name String @unique
refTable RefTable[]
}
It will generate this in schema.gql
type Mutation {
createExampleTable(
data: ExampleTableCreateInput!
): ExampleTable!
}
input ExampleTableCreateInput {
id: String
refTable: ExampleTableRefTableCreateNestedInput
}
input ExampleTableRefTableCreateNestedInput {
connect: [RefTableWhereUniqueInput!]
create: [RefTableCreateWithoutExampleTableInput!]
connectOrCreate: [RefTableConnectOrCreateWithoutExampleTableInput!]
}
input RefTableCreateWithoutExampleTableInput {
id: String
downstreamRefTable: RefTableDownstreamRefTableCreateNestedInput
downstreamRefTableId: String!
}
The downstreamRefTableId: String!
is now mandatory but it shouldn't because we have the downstreamRefTable as a reference (either by connect, create or connectOrCreate).
from prisma-appsync.
Got it! @StephanDecker could you please install [email protected]
and let me know if that resolves the issue on your end?
To clarify, this issue is specifically about the requirement of mandatory ID fields in the nested CreateWithout[Relation]Input
, even when using connect
or connectOrCreate
, correct? This isn't related to the @default
directives or the CreateInput
itself?
You can have a look at the fix here: e1a4ea7
from prisma-appsync.
Thanks a lot for the quick fix!!
To clarify, this issue is specifically about the requirement of mandatory ID fields in the nested CreateWithout[Relation]Input, even when using connect or connectOrCreate, correct? This isn't related to the @default directives or the CreateInput itself?
Exactly, it's about the mandatory ID fields in the nested CreateWithout[Relation]Input
. Sorry for the confusion before, I mixed that up. I tested the [email protected]
fix and the errors are gone. :-)
from prisma-appsync.
Thanks for confirming @StephanDecker! Fix was released as part of v1.0.2.
from prisma-appsync.
Related Issues (20)
- Issue: shield rule on model with WhereUniqueInput results in error HOT 8
- Issue: Shield ACL rules not compatible with count query and nested operations (breaking proposal) HOT 5
- Feature: new `unsecureGraphQLErrors` client option to enable unfiltered errors in GraphQL response HOT 3
- IntrospectionQuery fails on local server HOT 3
- @auth type public access HOT 2
- Local server does not take into account the data from the authorization token (AMAZON_COGNITO_USER_POOLS auth mode) HOT 2
- Public facing vs Admin facing apis
- Feat: migrate local dev server to Amplify AppSync Simulator HOT 2
- Issue: Schema generation issue when using Prisma `@@id` attributes. HOT 2
- AppSync producing empty GraphQL blocks in schema HOT 1
- Issue: Schema version mismatch when deploying HOT 4
- init -y flag not supported in pnpm HOT 2
- Issue: pnpm init empty string argument HOT 2
- Feature/Issue: AWSDate Type Serialization Issue with Override Decorator HOT 3
- Issue: tweaking graphql schema not working HOT 3
- Question: How to use multiple Lambda data sources? HOT 9
- Feature Request: Support for more granular @gql directives (for nested models)
- Delete operation: Argument `where` of type [Model]WhereUniqueInput needs at least one of `id` arguments. HOT 1
- Help: Large schema in AppSync is slow HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma-appsync.