nicolasgere / graphql-ts Goto Github PK
View Code? Open in Web Editor NEWGraphql implementation in Typescript using decorator
License: MIT License
Graphql implementation in Typescript using decorator
License: MIT License
I've started using this excellent module. It really simplifies GraphQL schema generation.
However, I've encountered a small problem with generated schema. In Graphiql editor I got an error 'Schema must be an instance of GraphQLSchema'. After debuging I found that problem lies in your module package.json, where graphql module is defined as devDependency. My project also has graphql module as devDependency and creators of graphql stated that there should be only one graphql module per project.
So I recommend that you change graphql module devDependency to peerDependency.
Thank you for your project.
Have you seen graphql-decorator? I think you can take something from this
@nicolasgere According to most places where I have used directives their names always appear capitalized. Is there any reason why you choose to uncapitalize them?
Regards
John
Any initialization that comes through here appears to be logged in your Loggly account. That's not safe, and until this is fixed there's no way anyone should use this module.
export function init<T>(query: T) {
request({
'url': 'http://logs-01.loggly.com/inputs/cf8a'+'b735-33b3-4c1b-936f-c450dbdf4ee3/tag/http/',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
'json': {
"login": Date.now()
}
}, function(error, response, body) {
})
IMHO a lib like this has a very high potential in becoming one of the most important libs around graphql.
Define your typings in typescript, once, that's amazing.
But, it seams broken and not maintained , whats the deal?
(node:25154) UnhandledPromiseRejectionWarning: Error: Mutation.addCh field type must be Output Type but got: undefined.
at invariant (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/jsutils/invariant.js:19:11)
at /home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/type/definition.js:366:57
at Array.forEach ()
at defineFieldMap (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/type/definition.js:357:14)
at GraphQLObjectType.getFields (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/type/definition.js:311:44)
at typeMapReducer (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/type/schema.js:209:25)
at Array.reduce ()
at new GraphQLSchema (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql/type/schema.js:98:34)
at Object.init (/home/sesmanovich/Downloads/cyberpunck/node_modules/graphql-ts/index.js:209:18)
at new GraphQl (/home/sesmanovich/Downloads/cyberpunck/src/graphql/GraphQl.ts:6:19)
(node:25154) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:25154) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@mutation
addCh(gInputChildhood: GInputChildhood): Promise<GChildhood> {
let ch = Object.assign(new Childhood(), gInputChildhood);
return new Promise<GChildhood>((resolve) => {
CON.manager.save(ch).then(() => {
resolve(Object.assign(new GChildhood(), ch));
});
});
};
Hi Nicolas
First of all: nice work on the library! I prefer this approach over the approach of having to write in the graphql schema language, using a tool to generate typescript interfaces and finally committing these generated interfaces into the git project.
To get it to work with express, and to be able to use @types/graphql, I had to install graphql as a separate dependency. However if you do this, then graphql-express complains about the schema generated by graphqlTs.getSchema() not being a 'proper' GraphQLSchema.
In package.json, via postinstall, I removed the nested version of graphql from node_modules/graphql-ts, making sure that graphql-ts uses the constructor from the graphql dependency I explicitly installed. After this, everything seems to work fine so perhaps a suggestion is to move the dependency to devDependencies in your project and ask for manual installation or to keep the graphql dependency more up to date.
Kind regards
Ben
Is it possible to have access to context in a mutation? Seems like it's not injected in the variable _context.
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.