Skip to content
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

Exists - Fields of type must have a sub selection #215

Closed
Jscott388 opened this issue Jul 30, 2018 · 10 comments
Closed

Exists - Fields of type must have a sub selection #215

Jscott388 opened this issue Jul 30, 2018 · 10 comments

Comments

@Jscott388
Copy link

For example, my schema is Media. I use the prisma.exists.Media({ListingID: 234523}).

I can't use Medias, media, media. only Media will work but returns this error. Tried using where with it but doesn't work either.

If there is another method to get this working, then update the docs on the site.

Error: Field 'medias' of type 'Media' must have a sub selection. (line 2, column 3):
medias(where: $_v0_where)

@shadowcodex
Copy link

I can confirm this is happening to me as well.

this.prisma.exists
      .User({
        address: "0x001",
      })
      .then(results => {
        console.log("exists results:", results);
      });

results in:

Error: Field 'users' of type 'User' must have a sub selection. 

@shadowcodex
Copy link

If I roll back to before 2.1.0 then I get an error that property length is undefined from the call. Seems to have been broken for a while. Hopefully someone can figure out what this is, for now I'll have to create my own exists query.

@divyenduz
Copy link
Contributor

@Jscott388 and @shadowcodex : Thanks for the feedback. Are you using JS or TS?
I tried to reproduce this one here: https://github.com/divyenduz/prisma-binding-215

But I am unable to do so, can you please provide more information about your setup or provide a reproduction repository or provide a PR in my reproduction attempt that displays the error?

That will help me more this forward. Thanks!

@apoggi-carecloud
Copy link

I am also having this issue. The ' Fields of type must have a sub selection' error occurs in version 2.0.1. Once I upgraded to 2.1.5 the error changed to a 'TypeError: Cannot read property length of undefined', which is occurring in the Prisma-Binding module.

@apoggi-carecloud
Copy link

Below is a sample resolver where using the exist method on the prisma-binding API creates an error.
Resolver:
async createComponents(_, { components }, ctx: IContext, info) { return components.map(async component => { try { const { mapping } = component; const componentExists = await ctx.db.exists.Component({ mapping }); return componentExists ? ctx.db.mutation.createComponent({ data: component }, info) : null; } catch (error) { console.log(error); } }); }
Datamodel:
type Component { name: String! mapping: String! @unique type: String! category: String! properties: Json! }
Error Message:
TypeError: Cannot read property 'length' of undefined at /Users/apoggi/code/MY_PRISMA_PROJECT/node_modules/prisma-binding/src/Prisma.ts:79:31 at <anonymous> at process._tickCallback (internal/process/next_tick.js:118:7)

@okankayhan
Copy link

Is there any progress on this or do I need to write my own exist methods ?

@shigurenimo
Copy link

Is there any solution?

@maticzav
Copy link
Collaborator

Hey 👋, does this still occur with the latest version of prisma-binding?

It would be very helpful if you could provide a reproduction repository or CodeSandbox so we can figure out the solution more quickly 🙂

@okankayhan
Copy link

@maticzav I managed to reproduce the problem using https://github.com/graphql-boilerplates/node-graphql-server/tree/master/advanced.

If you replace the id field of Post with uuid, any exist check starts returning Cannot read property 'length' of undefined. I am using a custom ID field to be able to create a new post with client specified ID.

@maticzav
Copy link
Collaborator

Closing in favour of #275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants