Skip to content

Commit

Permalink
🐛 fix(graphql): paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Teeoo committed Mar 21, 2020
1 parent 0c34634 commit b6390e6
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 30 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@angular/platform-browser": "~9.0.6",
"@angular/platform-browser-dynamic": "~9.0.6",
"@angular/router": "~9.0.6",
"@ngx-loading-bar/core": "^4.2.0",
"@ngx-loading-bar/router": "^4.2.0",
"apollo-angular": "^1.8.0",
"apollo-angular-link-http": "^1.9.0",
"apollo-cache-inmemory": "^1.6.5",
Expand Down
30 changes: 3 additions & 27 deletions src/app/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { SignIn } from './../../models/auth.model';
import { Injectable } from '@angular/core';
import { Apollo } from 'apollo-angular';
import { map } from 'rxjs/operators';
import gql from 'graphql-tag';
import { RootObject } from '../../models/auth.model';
import { RootObject, SignIn } from '@models/auth.model';
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
import { Observable } from 'rxjs';
import { QUERY_SIGNIN } from '@shared/graphql/queries/auth-queries';

@Injectable({
providedIn: 'root'
Expand All @@ -27,30 +26,7 @@ export class AuthService {

public SignIn(data: { name: string, password: string }) {
return this.apollo.watchQuery<RootObject>({
query: gql`
query($data: LoginUserInput!) {
SignIn(data: $data) {
accessToken
tokenType
expiresIn
User {
id
order
desc
createdAt
updatedAt
name
email
avatar
url
screenName
exInfo
lastIp
lastTime
}
}
}
`,
query: QUERY_SIGNIN,
variables: {
data
}
Expand Down
19 changes: 19 additions & 0 deletions src/app/shared/graphql/fragments/auth-fragments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import gql from 'graphql-tag';

export const USER = gql`
fragment User on User {
id
order
desc
createdAt
updatedAt
name
email
avatar
url
screenName
exInfo
lastIp
lastTime
}
`;
2 changes: 1 addition & 1 deletion src/app/shared/graphql/graphql.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth/auth.service';
import { AuthService } from '@services/auth/auth.service';
import { NgModule } from '@angular/core';
import { ApolloModule, Apollo } from 'apollo-angular';
import { HttpLinkModule, HttpLink } from 'apollo-angular-link-http';
Expand Down
16 changes: 16 additions & 0 deletions src/app/shared/graphql/queries/auth-queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import gql from 'graphql-tag';
import { USER } from '../fragments/auth-fragments';

export const QUERY_SIGNIN = gql`
query($data: LoginUserInput!) {
SignIn(data: $data) {
accessToken
tokenType
expiresIn
User {
...User
}
}
}
${USER}
`;
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"@models": ["app/models"],
"@models/*": ["app/models/*"],
"@pages": ["app/pages"],
"@pages/*": ["app/pages/*"]
"@pages/*": ["app/pages/*"],
"@graphql": ["app/shared/graphql"],
"@graphql/*": ["app/shared/graphql/*"]
}
},
"angularCompilerOptions": {
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,20 @@
rxjs "6.5.3"
webpack-sources "1.4.3"

"@ngx-loading-bar/core@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@ngx-loading-bar/core/-/core-4.2.0.tgz#cf0cc209eb967bd7625c2cec565841890cd5e17e"
integrity sha512-sfVmsDoLr9zI7ylzPct4wefi6zWBPyekQIhJVhME3h9sPh8S+BHy5loKgUqiZR3YduRNr8boLh4GkHpL3eXEPg==
dependencies:
tslib "^1.7.1"

"@ngx-loading-bar/router@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@ngx-loading-bar/router/-/router-4.2.0.tgz#e8a841b3d19b21db9b098e575c03d53ac14c697c"
integrity sha512-WFPzGDn25a9On3m0+sTGaHzj3/QAAU+LPX+ngNhSzqbJ8Kc0FJ5mKshVXRCgGZ9Wi2jjOKKRODTssS8lPMIdgA==
dependencies:
tslib "^1.9.0"

"@schematics/angular@9.0.6":
version "9.0.6"
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-9.0.6.tgz#791f05f7a4ddaa77daece79377abebf0df6fb840"
Expand Down Expand Up @@ -8055,7 +8069,7 @@ tslib@1.10.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

tslib@^1.10.0, tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
tslib@^1.10.0, tslib@^1.11.1, tslib@^1.7.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==
Expand Down

0 comments on commit b6390e6

Please sign in to comment.