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: ...@@ -49,7 +49,7 @@ test:lint:
test:async: test:async:
stage: test stage: test
script: script:
- npm start - npm start &
- sleep 5 - sleep 5
- curl http://localhost:3000 - curl http://localhost:3000
- pkill node - pkill node
...@@ -60,8 +60,7 @@ test:async: ...@@ -60,8 +60,7 @@ test:async:
deploy_staging: deploy_staging:
stage: deploy stage: deploy
script: script:
- npm start & - npm start & sleep 5
- sleep 30
- exit 0 - exit 0
environment: environment:
name: staging name: staging
......
import server from './server'; import server from './server';
import router from './admin_view/admin_view'; import router from './admin_view/admin_view';
import colors from 'colors'; 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'; import path from 'path';
/** /**
......
...@@ -2,8 +2,11 @@ import express from 'express'; ...@@ -2,8 +2,11 @@ import express from 'express';
import bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import favicon from 'serve-favicon'; import favicon from 'serve-favicon';
import morgan from 'morgan'; import morgan from 'morgan';
import knex from '../db/knex_router';
import path from 'path'; import path from 'path';
import ldap_auth from './ldap_auth/ldap_auth'; import ldap_auth from './ldap_auth/ldap_auth';
import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
import { makeExecutableSchema } from 'graphql-tools';
/** /**
* @file server.js * @file server.js
...@@ -34,4 +37,32 @@ server.use(morgan('dev')); ...@@ -34,4 +37,32 @@ server.use(morgan('dev'));
// setting up ldap authentication // setting up ldap authentication
ldap_auth(server); 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; export default server;
...@@ -12,4 +12,4 @@ block content ...@@ -12,4 +12,4 @@ block content
input.form-control(type="search", name="columns") input.form-control(type="search", name="columns")
button.form-control(type="submit") Search button.form-control(type="submit") Search
| |
a(href="/graphql") Check GraphQL a(href="/graphiql") Check GraphQL
\ No newline at end of file \ 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