Skip to content
Snippets Groups Projects
Commit ffde0a39 authored by Wilson JALLET's avatar Wilson JALLET :money_with_wings:
Browse files

Implémentation GraphQL

Avec iGraphQL pour interagir avec le schéma GraphQL
parent 5d229fa7
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ test:lint:
test:async:
stage: test
script:
- npm start
- npm start &
- sleep 5
- curl http://localhost:3000
- pkill node
......@@ -60,8 +60,7 @@ test:async:
deploy_staging:
stage: deploy
script:
- npm start &
- sleep 30
- npm start & sleep 5
- exit 0
environment:
name: staging
......
import server from './server';
import router from './admin_view/admin_view';
import colors from 'colors';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import makeExecutableSchema from 'graphql-tools';
import knex from '../db/knex_router';
import path from 'path';
/**
......
......@@ -2,8 +2,11 @@ import express from 'express';
import bodyParser from 'body-parser';
import favicon from 'serve-favicon';
import morgan from 'morgan';
import knex from '../db/knex_router';
import path from 'path';
import ldap_auth from './ldap_auth/ldap_auth';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import { makeExecutableSchema } from 'graphql-tools';
/**
* @file server.js
......@@ -34,4 +37,32 @@ server.use(morgan('dev'));
// setting up ldap authentication
ldap_auth(server);
const typeDefs = `
type Query {
groups: [Group]
}
type Group {
name: String
id: Int
school: String
}
`;
const resolvers = {
Query: {
groups: () => knex.select().from('groups')
}
};
const schema = makeExecutableSchema({
typeDefs,
resolvers
});
server.use('/graphql', bodyParser.json(), graphqlExpress({schema}));
server.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql'}));
export default server;
......@@ -12,4 +12,4 @@ block content
input.form-control(type="search", name="columns")
button.form-control(type="submit") Search
|
a(href="/graphql") Check GraphQL
\ No newline at end of file
a(href="/graphiql") Check GraphQL
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment