jaydenseric / graphql-api-koa Goto Github PK
View Code? Open in Web Editor NEWGraphQL execution and error handling middleware written from scratch for Koa.
Home Page: https://npm.im/graphql-api-koa
License: MIT License
GraphQL execution and error handling middleware written from scratch for Koa.
Home Page: https://npm.im/graphql-api-koa
License: MIT License
Looking at this line I see that the presence of result.errors
causes graphql-api-koa
to drop anything in result.data
. I am quite sure that this is incorrect behavior.
It's quite common for an error to happen in one subset of a query. In this case graphql-js
bubbles it up to the first nullable ancestor, preserving all other trees. We probably don't want to throw out everything in this case.
Hey ๐
Is it possible to somehow use subscriptions?
Hey ๐
When error is thrown in middleware its status code is used in response.
However, when same error is thrown in resolver its status code doesn't affect response.
This feels strange and is probably why other libraries don't use custom http status codes in response ๐ค
I've trying this package out and I'm liking it
But one problem has arisen when using it, when I make a mistake in my graphql schema while in development, I should see what the error is, at least in the console, but what appears is just a generic error:
InternalServerError: GraphQL execute middleware `schema` option has GraphQL schema validation errors.
is there a configuration to show that error? thanks, right now I've put a console.error in node_modules/graphql-api-koa/lib/checkGraphQLSchema.js
don't we need ?
"eslintConfig": { "parser": "babel-eslint", ....
Hey friends!
I currently use graphql-api-koa
version 2.0.2 because it was the latest version when this project was started in 2019. I've been looking at updating to the latest graphql
version which requires updating to the latest version of this package, but that is blocked because our project is 100% Typescript and graphql-api-koa
is 100% .mjs
, which Typescript currently can't use.
Do you have any suggestions or recommendations for using this project without copying the whole thing into my project and changing the filetypes from .mjs
to .ts
?
[email protected]:chentsulin/awesome-graphql.git
Hey ๐
This is a feature request for a function, similar to apollo formatError one.
It is very useful when you want to handle all errors in a single place, log them, etc. Handling this in resolvers across all app is tiresome.
If any equivalent or workaround exists, please suggest.
Upd: from twitter dm I found out that koa middlewares is current way of handling this. However, I find using formatError prop easier to undestand and use, maybe it's possible to add it to current api:
Is this meant to be 0.13.2?
It would be nice to be able to reformat error in errorHandler
. It's useful when you need to modify error before sending to client, for example:
Internal server error
message to other languageThe api might be as simple as:
function formatError(error) {
// do something with error
}
errorHandler(formatError)
I keep hitting this actually simple cases where I just want to format my errors before sending them to client and current errorHandler
is too restrictive in what I can do. However, I'm trying to avoid writing custom middleware instead of errorHandler
and struggling to find solutions.
@jaydenseric help ๐
Jesus, I've spent so much time to find how to do it.
http-errors
has possibility to add additional fields to error like this:
createError(503, 'No work on the sabbath.', { type: 'DayError' , expose: true })
However, formatError function cuts all additional properties and produces only message
field. To add this additional error fields you have to use extensions
property like this:
createError(503, 'No work on the sabbath.', { extensions: { type: 'DayError' }, expose: true })
This will correctly show additional error information to user:
Please, add this to docs somewhere. I really hope it will help and save time for someone else.
โค๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.