Giter VIP home page Giter VIP logo

Comments (11)

kbrandwijk avatar kbrandwijk commented on May 25, 2024 2

This is most probably an issue in the underlying graphql-binding. I will investigate, and move the issue if that turns out to be the case.

from prisma-binding.

divyenduz avatar divyenduz commented on May 25, 2024 1

I have a reproduction here: https://github.com/divyenduz/prisma-binding-76

from prisma-binding.

kbrandwijk avatar kbrandwijk commented on May 25, 2024 1

@divyenduz Looking at the repo example, I'm not sure if it's actually a clean reproduction. At least, if I understand the readme correctly, it fails with an invalid field. The example from @maticzav failed when there were no scalar fields present at a specific level. I'll try to look into it either.

from prisma-binding.

marktani avatar marktani commented on May 25, 2024

This might be related to #73 as well.

from prisma-binding.

kbrandwijk avatar kbrandwijk commented on May 25, 2024

The current workaround is to use a different fieldname in your datamodel.

from prisma-binding.

maticzav avatar maticzav commented on May 25, 2024

Thanks, I’ll use the workaround. Do you maybe have any plans to fix this in near future/have idea about when this is going to be resolved?

from prisma-binding.

maticzav avatar maticzav commented on May 25, 2024

Fixed.

from prisma-binding.

maticzav avatar maticzav commented on May 25, 2024

Hey 👋,

It seems like this is still unresolved. @kbrandwijk, I think this concerns you the most since I think this is graphql-binding problem. I won't be able to present the actual problem we are having because it's part of the internal code but I'll try to create a reproduction example in the following days.

So, so far I've been able to figure out that fragments are poorly applied to nested fields or not at all in some very particular situations.

# schema.graphql

type User {
  id: ID!
  teaching_classrooms: UserTeachingClassrooms!
}

type UserStudyingClassrooms {
  classrooms: [Classroom!]!
  count: Int!
}
# This one works
query {
  viewer {
    user {
        teaching_classrooms {
        count
        classrooms {
          id
          name
        }
      }
    }
  }
}

# This one doesn't
query {
  viewer {
    user {
        teaching_classrooms {
        # count
        classrooms {
          id
          name
        }
      }
    }
  }
}
// resolvers.ts
export const UserTeachingClassrooms = {
  classrooms: {
    fragment: `fragment UserID on User { id }`,
    resolve: async ({ id }, args, ctx: Context, info) => {
      return ctx.db.query.classrooms(
        {
          where: { teacher: { id } },
        },
        info,
      )
    },
  },
  count: {
    fragment: `fragment UserID on User { id }`,
    resolve: async ({ id }, args, ctx: Context, info) => {
      const classrooms = await ctx.db.query.classroomsConnection(
        {
          where: { teacher: { id } },
        },
        ` { aggregate { count } } `,
      )

      return classrooms.aggregate.count
    },
  },
}
# Prisma forwarded first case - working
query ($_v0_where: UserWhereUniqueInput!) {
  user(where: $_v0_where) {
    teaching_classrooms {
      ... on Classroom {
        id
      }
    }
  }
}

# Prisma forwarded second case - error
query ($_v0_where: UserWhereUniqueInput!) {
  user(where: $_v0_where) {
    teaching_classrooms
  }
}

I think this is an issue with fragment application, but I am not 💯 sure yet. I'll try and look into this. It would be super helpful if you could explain the idea behind how fragments are applied because looking into the bare code and figuring out what it does takes me significantly more time compared to if I knew the idea behind it.

from prisma-binding.

divyenduz avatar divyenduz commented on May 25, 2024

@maticzav : Are you on latest versions of binding libraries? If yes, can you please provide a minimal reproduction in form of a github project? Let us move this forward together.

A lot of fragment naming stuff was resolved in graphql-tools 3.x which should reflect in binding as well and this issue is worth revalidating.

This change log is a good summary of fixes in 3.x.x.

Thanks.

from prisma-binding.

maticzav avatar maticzav commented on May 25, 2024

Hey @divyenduz, yes, I think I am - my version of binding is 2.0.2 were the changes made in 2.1.0?

Besides that, I decided to solve the problem a bit differently. I am in a bit of a hurry with the current project so I might postpone this a bit - for about a week or so. But certainly, let's try to fix this together!

from prisma-binding.

divyenduz avatar divyenduz commented on May 25, 2024

@maticzav : I tried to replicate this with the latest stack but so far no luck. Would be great if we can make a reproduction repo around this.

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.