Skip to content

Commit

Permalink
Merge pull request #3 from tomermoshe/feat/graphql-code-generator
Browse files Browse the repository at this point in the history
Feat/graphql code generator
  • Loading branch information
tomermoshe authored May 28, 2017
2 parents 5e28769 + 04dd630 commit 613c84e
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 35 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"server": "nodemon --exec ts-node mock-server/index.ts"
"server": "nodemon --exec ts-node mock-server/index.ts",
"generate:types": "gql-gen --url http://localhost:3000/graphql --template typescript --out src/app/graphql/types/types.ts -- ./src/**/*.graphql "
},
"private": true,
"dependencies": {
Expand All @@ -25,10 +26,11 @@
"apollo-angular": "^0.13.0",
"apollo-client": "^1.3.0",
"core-js": "^2.4.1",
"global": "^4.3.2",
"graphql-tag": "^2.2.0",
"ionic-angular": "^3.2.1",
"ionicons": "^3.0.0",
"momentjs": "^2.0.0",
"moment": "^2.18.1",
"rxjs": "^5.1.1",
"zone.js": "^0.8.10"
},
Expand Down
13 changes: 13 additions & 0 deletions src/app/graphql/chat/chat.query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query GetChat{
me{
username
email

}
messages(channelId: "sdd", SearchRegex: ""){
content
user{
username
}
}
}
18 changes: 0 additions & 18 deletions src/app/graphql/chat/chat.query.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/app/graphql/get-chat-dummy.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Injectable } from '@angular/core';
import { Apollo } from 'apollo-angular';
import { chatQuery } from './chat/chat.query';
import { DocumentNode } from 'graphql';

const chatQuery: DocumentNode = require('graphql-tag/loader!./chat/chat.query.graphql');
// Will be removed
@Injectable()
export class GetChatDummyService {

constructor(private apollo: Apollo) { }

queryChat(){

return this.apollo.watchQuery({query: chatQuery});
}

Expand Down
236 changes: 236 additions & 0 deletions src/app/graphql/types/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/* tslint:disable */

export interface Query {
me: User | null;
messages: Array<Message> | null;
channelsByUser: Array<Channel> | null;
channels: Array<Channel> | null;
}

export interface MessagesQueryArgs {
channelId: string;
paginationId: string | null;
count: number | null;
SearchRegex: string | null;
}

export interface ChannelsByUserQueryArgs {
userId: string | null;
}

export interface ChannelsQueryArgs {
filter: ChannelFilter | null;
}

export interface User {
username: string;
status: UserStatus | null;
email: string;
avatar: string | null;
name: string | null;
lastLogin: string | null;
userPreferences: UserPreferences;
channels: Array<Channel> | null;
directMessages: Array<Channel> | null;
}

export type UserStatus = "ONLINE" | "AWAY" | "BUSY" | "INVISIBLE";

export interface UserPreferences {
language: string | null;
notificationDuration: number | null;
unreadTrayIconAlert: boolean | null;
useEmojis: boolean | null;
convertAsciiToEmoji: boolean | null;
autoLoadImages: boolean | null;
saveMobileBandwith: boolean | null;
collapseEmbeddedMeida: boolean | null;
unreadRoomsMode: boolean | null;
hideUserName: boolean | null;
hideRoles: boolean | null;
hideRightSideBarWithClick: boolean | null;
hideAvatars: boolean | null;
mergePrivateGroupsWithChannels: boolean | null;
enterKeyBehaviour: string | null;
viewMode: string | null;
offlineEmailNotifications: string | null;
highlights: string | null;
newRoomNotificationSound: string | null;
newMessageNotificationSound: string | null;
}

export interface Channel {
id: string;
title: string;
description: string;
announcement: string;
numberOfMembers: number;
members: Array<User> | null;
owners: Array<User> | null;
direct: boolean | null;
private: boolean | null;
readOnly: boolean | null;
archived: boolean | null;
favorite: boolean | null;
unseenMessages: number | null;
}

export interface Message {
id: string;
user: User;
content: string;
creationTime: string;
fromServer: boolean | null;
tags: Array<string> | null;
userRef: Array<User> | null;
channelRef: Array<Channel> | null;
reactions: Array<Reaction> | null;
}

export interface Reaction {
username: string;
icon: string;
}

export interface ChannelFilter {
nameFilter: string | null;
privacy: Privacy | null;
joinedChannels: boolean | null;
sortBy: ChannelSort | null;
}

export type Privacy = "PRIVATE" | "PUBLIC" | "ALL";

export type ChannelSort = "NAME" | "NUMBER_OF_MESSAGES";

export interface Mutation {
leaveChannel: boolean | null;
hideChannel: boolean | null;
setStatus: User | null;
logout: boolean | null;
createChannel: Channel | null;
sendMessage: Message | null;
deleteMessage: boolean | null;
editMessage: Message | null;
addReactionToMassage: Message | null;
updateUserSettings: User | null;
}

export interface LeaveChannelMutationArgs {
channelId: string;
}

export interface HideChannelMutationArgs {
channelId: string;
}

export interface SetStatusMutationArgs {
status: UserStatus;
}

export interface CreateChannelMutationArgs {
name: string;
private: boolean | null;
readOnly: boolean | null;
membersId: Array<string>;
}

export interface SendMessageMutationArgs {
channelId: string;
messageInput: MessageInput;
}

export interface DeleteMessageMutationArgs {
messageId: MessageIdentifier;
}

export interface EditMessageMutationArgs {
messageId: MessageIdentifier;
messageInput: MessageInput;
}

export interface AddReactionToMassageMutationArgs {
messageId: MessageIdentifier;
icon: string;
}

export interface UpdateUserSettingsMutationArgs {
userSettings: UserSettings | null;
}

export interface MessageInput {
content: string;
userRef: Array<string> | null;
channelRef: Array<string> | null;
}

export interface MessageIdentifier {
channelId: string;
messageId: string;
}

export interface UserSettings {
language: string | null;
notificationDuration: number | null;
unreadTrayIconAlert: boolean | null;
useEmojis: boolean | null;
convertAsciiToEmoji: boolean | null;
autoLoadImages: boolean | null;
saveMobileBandwith: boolean | null;
collapseEmbeddedMeida: boolean | null;
unreadRoomsMode: boolean | null;
hideUserName: boolean | null;
hideRoles: boolean | null;
hideRightSideBarWithClick: boolean | null;
hideAvatars: boolean | null;
mergePrivateGroupsWithChannels: boolean | null;
enterKeyBehaviour: string | null;
viewMode: string | null;
offlineEmailNotifications: string | null;
highlights: string | null;
newRoomNotificationSound: string | null;
newMessageNotificationSound: string | null;
email: string | null;
avatar: string | null;
name: string | null;
}

export interface scheme {
query: Query | null;
mutation: Mutation | null;
}

export interface ChannelSettings {
disableNotification: boolean | null;
audio: string | null;
desktop: string | null;
duration: number | null;
mobile: string | null;
mail: string | null;
hideUnreadRoomStatus: boolean | null;
unreadTrayIconAlert: string | null;
}

export namespace GetChatQuery {
export type Variables = {
}

export type Result = {
me: Me;
messages: Array<Messages>;
}

export type Me = {
username: string;
email: string;
}

export type Messages = {
content: string;
user: User;
}

export type User = {
username: string;
}
}
2 changes: 1 addition & 1 deletion src/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
"types": ["node"]
},
"exclude": [
"test.ts",
Expand Down
Loading

0 comments on commit 613c84e

Please sign in to comment.