diff --git a/src/graphql/schema.js b/src/graphql/schema.js index 844298716a5bdcbb534a56d292732df1110c513f..720f983a2a8081d20dda52573eebf202740c4697 100644 --- a/src/graphql/schema.js +++ b/src/graphql/schema.js @@ -4,9 +4,12 @@ */ import { makeExecutableSchema } from 'graphql-tools'; -import typeDefs from './typeDefs'; +import actionDefs from './typeDefs/actions'; +import objectDefs from './typeDefs/objects'; import { resolvers } from './resolvers'; +const typeDefs = actionDefs.concat(objectDefs); + const schema = makeExecutableSchema({ typeDefs, resolvers diff --git a/src/graphql/typeDefs/actions.js b/src/graphql/typeDefs/actions.js new file mode 100644 index 0000000000000000000000000000000000000000..53a982caeb0e23860aa0b4ba87f297f85cc7356c --- /dev/null +++ b/src/graphql/typeDefs/actions.js @@ -0,0 +1,136 @@ +const RootTypes = ` + # Requêtes + type Query { + accessGroups : GroupQuery + accessPosts : MessageQuery + accessUsers : UserQuery + + asAdmin(groupUID: ID): AdminQuery + asSpeaker(groupUID: ID): AdminQuery + asMember(groupUID: ID): MemberQuery + asViewer(groupUID: ID): AdminQuery + + } + + type Mutation { + asAdmin(groupUID: String): AdminMutation + asSpeaker(groupUID: String): SpeakerMutation + asMember(groupUID: String): MemberMutation + asViewer(groupUID: String): ViewerMutation + } + + +`; + +const subMutations = ` + type AdminMutation { + + isAdmin: Boolean + + createSubgroup( + uid: ID = null, + name: String, + website: String, + description: String, + school: String + ): Group + + addUser(userid : String): User + removeUser(userid : String): User + addAdmin(userid : String): User + removeAdmin(userid : String): User + + editGroup( + name: String, + website: String, + description: String, + school: String + ): Group + + } + + type SpeakerMutation{ + postEvent(name: String, date: String): Event + answerEventRequest(request: ID, accept : Boolean): Request + } + + type MemberMutation { + leave: Group + } + + type ViewerMutation { + requestJoin: Group + } + + +`; + +const subQueries = ` + + """ + Requête pour obtenir un groupe. + """ + type GroupQuery{ + allGroups: [Group] + allSimpleGroups: [SimpleGroup] + + group(uid: ID) : Group + simpleGroup(uid : ID) : SimpleGroup + metaGroup(uid : ID) : MetaGroup + + } + + """ + Requête pour obtenir un message. + """ + type MessageQuery{ + allMessages: [Message] + allEvents: [Event] + allPosts: [Post] + post(id: ID): Post + allAnnouncements: [Announcement] + } + + type UserQuery{ + + user(uid: ID) : User + + searchTOL( + givenName: String, + lastName: String, + nickname: String, + nationality: String, + school: String, + promotion: String, + groups: String, + studies: String, + sport: String, + phone: String, + mail: String, + adress: String, + ip: String + ): [String] + } + + # Requête à la base de donnée nécessitant d'être administrateur. + type AdminQuery{ + isAdmin: Boolean + allRequests : AllRequests + } + + type SpeakerQuery{ + isSpeaker: Boolean + } + + type MemberQuery{ + isMember: Boolean + allMembers : [Group] + } + + type ViewerQuery{ + isViewer: Boolean + } +`; + +const actionDefs = [RootTypes, subQueries ]; +export default typeDefs; diff --git a/src/graphql/typeDefs.js b/src/graphql/typeDefs/objects.js similarity index 60% rename from src/graphql/typeDefs.js rename to src/graphql/typeDefs/objects.js index 9bde8199ada1c7df3f1270e5b481352ff3c3eb05..454dabc24c384d6330983356271208051557a7f7 100644 --- a/src/graphql/typeDefs.js +++ b/src/graphql/typeDefs/objects.js @@ -1,136 +1,3 @@ -const RootTypes = ` - # Requêtes - type Query { - accessGroups : GroupQuery - accessPosts : MessageQuery - accessUsers : UserQuery - - asAdmin(groupUID: ID): AdminQuery - asSpeaker(groupUID: ID): AdminQuery - asMember(groupUID: ID): MemberQuery - asViewer(groupUID: ID): AdminQuery - - } - - type Mutation { - asAdmin(groupUID: String): AdminMutation - asSpeaker(groupUID: String): SpeakerMutation - asMember(groupUID: String): MemberMutation - asViewer(groupUID: String): ViewerMutation - } - - -`; - -const subMutations = ` - type AdminMutation { - - isAdmin: Boolean - - createSubgroup( - uid: ID = null, - name: String, - website: String, - description: String, - school: String - ): Group - - addUser(userid : String): User - removeUser(userid : String): User - addAdmin(userid : String): User - removeAdmin(userid : String): User - - editGroup( - name: String, - website: String, - description: String, - school: String - ): Group - - } - - type SpeakerMutation{ - postEvent(name: String, date: String): Event - answerEventRequest(request: ID, accept : Boolean): Request - } - - type MemberMutation { - leave: Group - } - - type ViewerMutation { - requestJoin: Group - } - - -`; - -const subQueries = ` - - """ - Requête pour obtenir un groupe. - """ - type GroupQuery{ - allGroups: [Group] - allSimpleGroups: [SimpleGroup] - - group(uid: ID) : Group - simpleGroup(uid : ID) : SimpleGroup - metaGroup(uid : ID) : MetaGroup - - } - - """ - Requête pour obtenir un message. - """ - type MessageQuery{ - allMessages: [Message] - allEvents: [Event] - allPosts: [Post] - post(id: ID): Post - allAnnouncements: [Announcement] - } - - type UserQuery{ - - user(uid: ID) : User - - searchTOL( - givenName: String, - lastName: String, - nickname: String, - nationality: String, - school: String, - promotion: String, - groups: String, - studies: String, - sport: String, - phone: String, - mail: String, - adress: String, - ip: String - ): [String] - } - - # Requête à la base de donnée nécessitant d'être administrateur. - type AdminQuery{ - isAdmin: Boolean - allRequests : AllRequests - } - - type SpeakerQuery{ - isSpeaker: Boolean - } - - type MemberQuery{ - isMember: Boolean - allMembers : [Group] - } - - type ViewerQuery{ - isViewer: Boolean - } -`; const User = ` # Utilisateurs @@ -264,7 +131,8 @@ const Event = ` # Organisateurs authors: [Group] # Personnes qui participent à l'événement. - participants: [User] + participatingGroups: [Group] + participatingUsers: [User] description: String } `; @@ -315,5 +183,5 @@ const Requests = ` `; -const typeDefs = [RootTypes, Group, User, Message, Post, Announcement, Event, subMutations, subQueries, Requests]; -export default typeDefs; +const objectDefs = [Group, User, Message, Post, Announcement, Event, subMutations, Requests]; +export default typeDefs; \ No newline at end of file