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

prisma.request Promise returns undefined on error #182

Closed
terion-name opened this issue Jun 2, 2018 · 8 comments · Fixed by dotansimha/graphql-binding#131
Closed

prisma.request Promise returns undefined on error #182

terion-name opened this issue Jun 2, 2018 · 8 comments · Fixed by dotansimha/graphql-binding#131
Assignees

Comments

@terion-name
Copy link

terion-name commented Jun 2, 2018

upd
More generalizing the issue — on any error prisma.reqest Promise silently returns undefined and it is simply impossible to debug anything. A huge, huge problem

A resolver:

import {
  ArticleFlatFragment,
  ArticleTranslationFlatFragment,
  TagFlatFragment,
  TagLabelFlatFragment,
  TypeFlatFragment,
  TypeLabelFlatFragment
} from "../../schema/generated/mysql.fragments"; // fragments are generated by my own

const fragments = {
  ArticleFlatFragment,
  ArticleTranslationFlatFragment,
  TagFlatFragment,
  TagLabelFlatFragment,
  TypeFlatFragment,
  TypeLabelFlatFragment
};

export const articleReturn = `{
  ...ArticleFlat 
  translations(where: {lang: $lang}, first: 1) { ...ArticleTranslationFlat }
  type ${require('../type/typesLocalized.resolvers').typeReturn}
  tags ${require('../tag/tagsLocalized.resolvers').tagReturn}
}`;

export async function articlesLocalized(_, args, ctx, info) {
  const req = `query($lang: String!) { 
    articles ${articleReturn} 
  }
  ${Object.values(fragments).join('\n')}
  `;
  console.log(req);
  const result = await ctx.prisma.request(req, {lang: ctx.lang}); // Prisma instance is injected `prisma` ctx property
  console.log(result);
  return result.map(entry => collapseArticle(entry));
}

result is undefined.

I copy from console entire request, run it directly over prisma server and it works:

2018-06-02 19 28 47

@terion-name terion-name changed the title prisma.reqest returns undefined prisma.reqest Promise returns undefined Jun 2, 2018
@terion-name
Copy link
Author

Ok, after fixing fragments (see graffle-js/graffle#86) it began to work.

BUT!

The issue is still present: the Promise should be rejecting on query error and messaging what was wrong, not just silently return undefined

@terion-name terion-name changed the title prisma.reqest Promise returns undefined prisma.reqest Promise returns undefined on error Jun 2, 2018
@marktani
Copy link
Contributor

Can you provide a reproduction for this behaviour? 🙂

@terion-name
Copy link
Author

@marktani in what form? a repo? is there a sort of template for this?

in any case just run await ctx.db. request('query { anyMalformedQuery() {} }') — that's all reproduction. You'll get undefined

@marktani
Copy link
Contributor

Awesome, that's already enough. Thanks! 🙂

@terion-name
Copy link
Author

@divyenduz any progress on this? it's a really big problem

@marktani
Copy link
Contributor

Hey @terion-name, we were focusing on the GraphQL Europe conference lately and haven't started to investigate this yet (the conference was amazing by the way!)

Did you consider providing a PR? 🙂

@terion-name
Copy link
Author

@marktani I'd be happy, but I'm not so confident in your source code. As far as I understand you use for this graphql-request, and issue is common for prisma-binding and for generic graphql-binding (faced it yesterday). So it seems to be problem in GraphQLClient... Well, I'll try to figure this out and make a PR if succeed

@marktani marktani changed the title prisma.reqest Promise returns undefined on error prisma.request Promise returns undefined on error Jun 23, 2018
@divyenduz
Copy link
Contributor

Currently, we pluck the data out of response and consume the error. Even showing this error via any will display only the schema side error.

There is already a broad proposal to get around this issue that needs further discussion.

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

Successfully merging a pull request may close this issue.

3 participants