Skip to content

psmtec/hxjs-apollo-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

hxjs-apollo-express

tested npm dependencies

  • apollo-server-express 1.3.0

usage

import js.npm.Express; // https://github.com/clemos/haxe-js-kit.git
import js.npm.express.*; // https://github.com/clemos/haxe-js-kit.git
import apollo.Express.graphqlExpress;
import apollo.Express.graphiqlExpress;
import GraphQLTools.makeExecutableSchema;

class Main {
    public static function main() {
        var executableSchema = makeExecutableSchema({
            typeDefs: {
                type Query {
                    hello: String!
                }

                schema {
                    query: Query
                }
            },
            resolvers: {
                Query: {
                    hello: function() {
                        return 'world';
                    }
                }
            },
            printErrors: true,
        });

        var app = new Express();

        app.use('/graphql', graphqlExpress(function( req ) {
            return {
                schema: executableSchema,
                context: context,
            }
        }));

        app.use('/graphiql', graphiqlExpress({
            endpointURL: '/graphql',
        }));

        app.listen(3000, function() {
            trace('\\o/');
        });
    }
}