ammezie / adonis-apollo-server Goto Github PK
View Code? Open in Web Editor NEWProduction-ready Node.js GraphQL server for AdonisJS
Production-ready Node.js GraphQL server for AdonisJS
Hi,
I use adonis-apollo-server(^1.0.2) extension to create my own graphQL api.
Query request works fine, but when I use Mutation query, I have got this request error:
POST http://localhost:3333/graphql net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH ApolloError.js:34 Uncaught (in promise) Error: Network error: Failed to fetch at new ApolloError (ApolloError.js:34) at Object.error (QueryManager.js:122) at SubscriptionObserver.error (zen-observable.js:174) at httpLink.js:147 at
I tryed to change cors configs, but no changes.
With another graphQL API (express), I have not this error.
Thx for helping
Hello, please, I beg you earlier the new version apollo-server-adonis
Supporting the new Apollo Server would be a nice feature, huh? :)
Is it planned?
Could anyone provide an example of using the adonis authentication with this?
For example, I have a login resolver, where I want to create a JWT Token and return it to the user.
login: async (parent, args, { auth }, info) => {
try {
const token = await auth.attempt(args.auth)
return { token }
} catch (error) {
throw new GraphQLError(error.message)
}
}
I can see auth is passed in the context, but it just returns "Cannot convert object to primitive value" when I try to use it like the above. Would be glad of any help.
Thanks
It appears that error handling is broken. The HTTP status is returned in statusCode
attribute, rather than status
for errors coming from GraphQL middleware.
But, on top of that, I am questioning the need to handle errors there at all. Why not just let the error bubble up and be dealt with by an exceptions handler (app/Exceptions/Handler.js
), which does need to be user-defined, but maybe add instructions for that.
Not sure if I am describing the issue correctly in the subject, but here is the problem. When I am throwing in a custom type, it actually results in a wrong error:
RangeError [ERR_HTTP_INVALID_STATUS_CODE]
Invalid status code: undefined
Example of a custom type definition:
const { InvalidArgumentException } = require('@adonisjs/generic-exceptions')
const Email = new GraphQLScalarType({
name: 'Email',
description: 'Email address.',
parseValue (value) {
return value
},
serialize (value) {
return value
},
parseLiteral (ast) {
if (emailValidator.validate(ast.value)) {
return ast.value.toLowerCase()
} else {
throw new InvalidArgumentException('Not a valid email.', 400, 'E_INVALID_ARGUMENT')
}
}
})
Stack:
Side Note:
Not sure if relevant, but throwing from a mutator query works just fine and the errors get handled correctly.
Any plans to make this compatible with Subscription Server?
This package is amazing, and everywhere we go, it points to this... but we are missing some featueres, so, there's any plan to update this ?!
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.