geek / graphi Goto Github PK
View Code? Open in Web Editor NEWhapi graphql plugin
License: Mozilla Public License 2.0
hapi graphql plugin
License: Mozilla Public License 2.0
config.payload.maxBytes
propertyHi, currently Im facing an issue with image uploads, and receiving "Request entity too large". I've managed to track this down to the config.payload.maxBytes
option included in the server.route
configuration, by manually editing my local node_modules/graphi
to contain the property. I was wondering if there was anyway I could either:
config
(through some parameter or config Im missing).Thanks in advance for the help!
Closed by 99bcb8a
@geek what do you think about adding support for hapi authStrategies?
My PR #6 adds the feature.
Details:
./graphql
is the default graphi query route.Hello Sir, when applying an authentication strategy (for example jwt) to the option: authStrategy this means that no graphql request can be made if there is no authentication token sent. Since some graphql resolvers will require authentication and not others, my question is how to apply authentication only on resolvers that require authentication and not to all resolvers. thanks
I'm working on migrating from hapi-graphql-2 and one of the things I'm stuck on is its context object. I used it to easily pass in the ORM models, current user, and a reference to a REST API.
There isn't anything like it in your library, is there? I looked around but couldn't find it.
(Obviously, I can just put these various references in the code but I liked the "cleanliness" of defining it at plugin registration and relying on its presence.)
it('will handle nested queries', (done) => {
const schema = `
type Person {
firstname: String!
lastname: String!
friends(firstname: String): [Person]!
}
type Query {
person(firstname: String!): Person!
}
`;
const getPerson = function (args, request) {
expect(args.firstname).to.equal('billy');
expect(request.path).to.equal('/graphql');
expect(args.friends).to.equal({ firstname: 'jose' });
return new Promise((resolve) => {
resolve({ firstname: 'billy', lastname: 'jean', friends: [] });
});
};
const resolvers = {
person: getPerson
};
const server = new Hapi.Server();
server.connection();
server.register({ register: Graphi, options: { schema, resolvers } }, (err) => {
expect(err).to.not.exist();
const payload = { query: '{ person(firstname: "billy") { friends(firstname: "jose") { lastname } } }' };
server.inject({ method: 'POST', url: '/graphql', payload }, (res) => {
expect(res.statusCode).to.equal(200);
const result = JSON.parse(res.result);
expect(result.data.person.lastname).to.equal('jean');
done();
});
});
});
const ISODateString = new GraphQLScalarType({
name: 'ISODateString',
description: 'An ISO 8601 formatted date string',
parseValue(value) {
return new Date(value);
},
serializeValue(value) {
return value.toISOString();
},
parseLiteral(ast) {
switch (ast.kind) {
case Kind.STRING:
return new Date(ast.value);
default:
return null;
}
}
});
const schema = server.makeExecutableSchema({
schema: mergeTypeDefs(typesArray, {
commentDescriptions: true
}),
resolvers: { ISODateString }
});
AssertionError [ERR_ASSERTION]: ISODateString.name resolver must be a function
at internals.Server.exports.makeExecutableSchema (/code/node_modules/graphi/lib/utils.js:26:7)
at Object.register (/code/node_modules/graphi-aws/lib/index.js:34:25)
at internals.Server.register (/code/node_modules/@hapi/hapi/lib/server.js:500:35)
at async main (/code/server.js:115:5) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
I expected the ISODateString resolver to successfully override the ISODateString type in the schema.
3.0.0 drops reliance on the apollo core server module. Instead, compatibility is maintained by depending directly on graphql. Additionally, there is now better validation of the incoming query against the schema.
Other than removing an unnecessary dependency, this release achieves 100% code coverage.
Return a 400 when the request query includes features that the graphql schema can't support. For example, if you are making a request with graphql directives and the schema can't process them, they will no longer fail silently, instead you get a 400 response.
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.