diff --git a/src/graphql/schema.js b/src/graphql/schema.js index 47f67ea30eea7edb0569fe64e36279cc36f29faa..215452e9c2f1fab5b859ca59e7d1e573f0c93562 100644 --- a/src/graphql/schema.js +++ b/src/graphql/schema.js @@ -8,6 +8,8 @@ import { makeExecutableSchema } from 'graphql-tools'; import { request } from 'https'; import { assertBinaryExpression } from 'babel-types'; +import { Group, User } from './user_and_group'; + const typeDefs = ` type Query { allGroups: [Group] @@ -15,28 +17,6 @@ const typeDefs = ` user(uid: ID) : [User] } - type Group { - uid: ID - name: String - website: String - createdAt: String - updatedAt: String - description: String - school: String - parentuid: String - } - - type User { - givenName: String! - lastName: String! - uid: ID! - birthdate: String! - mail: String - phone: String - groups: [String] - address: String - } - type Mutation { asAdmin(groupid: String): AdminMutation asMember(groupid: String): MemberMutation @@ -233,7 +213,7 @@ const resolvers = { }; const schema = makeExecutableSchema({ - typeDefs, + typeDefs: [typeDefs, Group, User], resolvers }); diff --git a/src/graphql/user_and_group.js b/src/graphql/user_and_group.js new file mode 100644 index 0000000000000000000000000000000000000000..be03a20ce8fe296933a3465e7e2b8669e8652e1d --- /dev/null +++ b/src/graphql/user_and_group.js @@ -0,0 +1,27 @@ +const User = ` + type User { + givenName: String! + lastName: String! + uid: ID! + birthdate: String! + mail: String + phone: String + groups: [Group] + address: String + } +`; + +const Group = ` + type Group { + uid: ID + name: String + website: String + createdAt: String + updatedAt: String + description: String + school: String + parentuid: String + } +`; + +export { Group, User }; \ No newline at end of file diff --git a/src/server.js b/src/server.js index f98d163e6d8b538f092e3a9537adceac5cfb8dda..39e8192fd9df7b37e26a79319747478f0e20874d 100644 --- a/src/server.js +++ b/src/server.js @@ -9,6 +9,7 @@ import path from 'path'; import cors from 'cors'; import schema from './graphql/schema'; import setupLdapAuth from './ldap/ldap_auth'; +import { express as graphqlVoyager } from 'graphql-voyager/middleware'; import { graphqlExpress, graphiqlExpress } from 'graphql-server-express'; import flash from 'connect-flash'; @@ -65,6 +66,9 @@ server.use('/graphql', bodyParser.json(), cors(), // GraphiQL est une console interactive pour faire des requêtes au schéma GraphQL server.use('/graphiql', graphiqlExpress({endpointURL: '/graphql'})); +// GraphQL voyager +server.use('/voyager', graphqlVoyager({ endpointUrl: '/graphql' })); + // connect-flash is middleware for flashing messages server.use(flash());