Giter VIP home page Giter VIP logo

Comments (13)

marktani avatar marktani commented on May 24, 2024 2

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.

schickling avatar schickling commented on May 24, 2024 2

Thanks a lot @divyenduz and @timsuchanek for digging into this. Looking forward to a fix @freiksenet! 🎉

from prisma-binding.

KATT avatar KATT commented on May 24, 2024 1

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.

divyenduz avatar divyenduz commented on May 24, 2024 1

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.

k00k avatar k00k commented on May 24, 2024 1

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.

divyenduz avatar divyenduz commented on May 24, 2024 1

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.

marktani avatar marktani commented on May 24, 2024

Thanks for the report @michaelchiche!

I propose either of the following changes:

  • support calling a variable data (or where 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.

marktani avatar marktani commented on May 24, 2024

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.

anonymous-coder avatar anonymous-coder commented on May 24, 2024

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.

marktani avatar marktani commented on May 24, 2024

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.

anonymous-coder avatar anonymous-coder commented on May 24, 2024

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.

nathanforce avatar nathanforce commented on May 24, 2024

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.

divyenduz avatar divyenduz commented on May 24, 2024

@nathanforce : Can you please create a new issue for this? Thanks :)

from prisma-binding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.