Comments (13)
You need to add @unique
to your datamodel, which is often called prisma.graphql
, or types.graphql
, not your application schema, which is often called schema.graphql
🙂
from prisma-binding.
Thanks a lot @divyenduz and @timsuchanek for digging into this. Looking forward to a fix @freiksenet! 🎉
from prisma-binding.
My workaround was to using input
instead of data
as the convention in my API Gateway.
Would be nice to fix though, I try to follow the conventions of Prisma in my API Gateway to simplify dev experience
from prisma-binding.
I can confirm that this issue is indeed in graphql-tools
. This issue can be replicated via master
branch in this repository, README has instructions.
While, in this branch, it is confirmed that this issue is no longer replicable in graphql-tools@next
as the variable generations stuff is fixed in it.
Thanks to @timsuchanek for helping me with the setup and investigation 🙌.
Also, there are some changes in the API of graphql-tools@next
in delegateToSchema
. Although, Mikhail suggested that he might make it backward compatible but we might need to make changes to in Handler.ts (arguments order) when we bump up graph-tools
to next.
from prisma-binding.
Just to confirm, this does happen with where
as well. For example, when trying to compound a where
clause in a resolver, this compounded where
in the resolver is completely ignored:
return context.db.query.games({ where: { AND: [{ active: true }, { ...args.where }] } }, info)
from prisma-binding.
I can confirm that this is resolved in the latest stack
"graphql-yoga": "1.14.10"
"prisma-binding": "2.1.0"
Because prisma-binding
relies on graphql-tools
3.x
and this is resolved there.
from prisma-binding.
Thanks for the report @michaelchiche!
I propose either of the following changes:
- support calling a variable
data
(orwhere
for other cases) - generally all variable names should be allowed - or, if that is not possible for whatever reason, a friendly, precise and helpful error message should be shown in the logs that warns the developer and asks them to rename their variable
from prisma-binding.
I believe this is rooted in a bug in graphql-tools, but haven't had the chance to verify yet. If anyone wants to take a stab at looking closer into this, let me know 🙌
from prisma-binding.
not sure why im getting:
Error: Variable "$_where" got invalid value {"facebookUserId":"xxxxxxxxxx"}; Field
"facebookUserId" is not defined by type UserWhereUniqueInput.
graphQL request (2:3)
1: mutation{
2: facebookUser(facebookToken: "xxxxx") {
^
3: token
on this:
async function facebookUser(parent, { facebookToken }, context, info) {
let user = null
try {
const facebookUser = await getFacebookUser(facebookToken)
user = await context.db.query.user(
{ where: { facebookUserId: facebookUser.id } },
info,
)
if (!user) {
user = await createUserFromFacebook(context, facebookUser)
}
return {
token: jwt.sign({ userId: user.id }, APP_SECRET),
user,
}
} catch (error) {
throw new Error(error)
}
}
Ive defined facebookUserId on my User Type
sorry if im missing something simple, long week
from prisma-binding.
Hey @anonymous-coder, thanks for sharing your problem here 🙂 I believe I sent you here by mistake, now looking at your question again.
It looks like the field facebookUserId
is missing the @unique
directive in your datamodel.
Can you add it, then deploy again? This should make the facebookUserId
argument available for the unique where selection.
Here's an example:
type User {
id: ID! @unique
name: String!
- facebookUserId: String!
+ facebookUserId: String! @unique
}
If that's not your issue, then additonally share your application schema schema.graphql
🙂
from prisma-binding.
whenever i put @unique i get this error:
throw new Error("Directive " + directiveName + ": Couldn't find type " + directiveName + "
in any of the schemas.");
^
Error: Directive unique: Couldn't find type unique in any of the schemas.
this was a issue i had with just the Id field.
# import Post from "./generated/prisma.graphql"
type Query {
feed(filter: String, skip: Int, first: Int, orderBy: PostOrderByInput): Feed!
loggedInUser: loggedInUserPayload!
post(id: ID!): Post!
me: User
}
type Feed {
posts: [Post!]!
count: Int!
}
type Mutation {
signup(email: String!, password: String!, firstName: String!, gender: String, birthday: String):
AuthPayload
login(email: String!, password: String!): AuthPayload
facebookUser(facebookToken: String!): FacebookUserPayload
post(title: String!, description: String!, preference: String, tags: String): Post!
deletePost(id: ID!): Post!
publish(id: ID!): Post!
}
type AuthPayload {
token: String
user: User
}
type FacebookUserPayload {
token: String!
}
type loggedInUserPayload {
id: ID!
}
type User {
id: ID! @unique
facebookUserId: String!
email: String!
firstName: String!
lastName: String
gender: String!
birthday: String!
locale: String
picture: String
posts: [Post!]!
}
type Subscription {
newPost: PostSubscriptionPayload
}
i would yarn prisma deploy to update schema after changes
from prisma-binding.
To chime in here, I am seeing the same with a variable called after
. If I change the variable to afterDate
then all works fine.
posts: async (
parent,
{ author, first, after },
context: Context,
info
) => {
return context.db.query.posts(
{
where: {
author: { id: author },
time: { start_gte: after },
},
first,
},
info
);
},
from prisma-binding.
@nathanforce : Can you please create a new issue for this? Thanks :)
from prisma-binding.
Related Issues (20)
- how to submit many transactions
- Connect Prisma Bindings to mock server
- Calling a query from Yoga to Prisma does nothing. HOT 5
- Case Sensitive Query Adjustments. HOT 2
- Calling multiple prisma requests returns same error to all the request if any one of them gives error.
- forwardTo() without having to specify resolver keys
- Cannot set property 'fragmentReplacements' of undefined HOT 1
- forwardTo with type rename
- how to get the count of records
- Howto define subscription endpoint
- Sub-selecting custom fields HOT 2
- Subscription Implementation with Prisma Binding
- Improve Code Readability
- error when trying to call aggregate function HOT 1
- Aliases still not works correctly
- How to filter `Where null` HOT 1
- Prisma() not recognized as a constructor HOT 1
- Import error on IResolvers from graphql-tools
- The automated release is failing 🚨
- Version of this for graphql-code-generator ?
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-binding.