Skip to content

Commit

Permalink
feat(packages): apollo
Browse files Browse the repository at this point in the history
  • Loading branch information
draylegend committed Sep 23, 2022
1 parent 64b6dfd commit 73e4d19
Show file tree
Hide file tree
Showing 12 changed files with 528 additions and 42 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
"jest": true
},
"rules": {}
},
{
"files": ["*.graphql"],
"parser": "@graphql-eslint/eslint-plugin",
"plugins": ["@graphql-eslint"],
"rules": {
"@graphql-eslint/known-type-names": "error"
},
"parserOptions": {
"schema": "./schema.graphql"
}
}
]
}
1 change: 1 addition & 0 deletions apps/angular-client/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const environment = {
api: '/graphql',
production: true,
};
14 changes: 1 addition & 13 deletions apps/angular-client/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
api: 'http://localhost:3333/graphql',
production: false,
};

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
4 changes: 2 additions & 2 deletions apps/angular-client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { enableProdMode } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { providers } from '@immomio/core/domain';
import { provideCore } from '@immomio/core/domain';
import { AppComponent } from './app/app.component';
import { environment } from './environments/environment';

environment.production && enableProdMode();

bootstrapApplication(AppComponent, {
providers: providers(environment),
providers: provideCore(environment),
}).catch(err => console.error(err));
2 changes: 1 addition & 1 deletion apps/nest-api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { environment } from '../environments/environment';
debug: !environment.production,
driver: ApolloDriver,
playground: !environment.production,
autoSchemaFile: './schema.gql',
autoSchemaFile: './schema.graphql',
}),
],
})
Expand Down
4 changes: 2 additions & 2 deletions libs/core/domain/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import providers from './lib/core.providers';
import provideCore from './lib/core.providers';

export { providers };
export { provideCore };
15 changes: 15 additions & 0 deletions libs/core/domain/src/lib/apollo.providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FactoryProvider } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
import { APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';

export default (env: { api: string; production: boolean }) =>
({
provide: APOLLO_OPTIONS,
useFactory: (httpLink: HttpLink) =>
({
cache: new InMemoryCache(),
link: httpLink.create({ uri: env.api }),
} as ApolloClientOptions<unknown>),
deps: [HttpLink],
} as FactoryProvider);
4 changes: 3 additions & 1 deletion libs/core/domain/src/lib/core.providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { EffectsModule } from '@ngrx/effects';
import { routerReducer, StoreRouterConnectingModule } from '@ngrx/router-store';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import provideApollo from './apollo.providers';
import routes from './routes';

export default (env: { production: boolean }) =>
export default (env: { api: string; production: boolean }) =>
[
importProvidersFrom(
HttpClientModule,
Expand All @@ -33,4 +34,5 @@ export default (env: { production: boolean }) =>
}),
),
provideRouter(routes),
provideApollo(env),
] as Provider[];
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@angular/platform-browser": "~14.2.0",
"@angular/platform-browser-dynamic": "~14.2.0",
"@angular/router": "~14.2.0",
"@apollo/client": "^3.6.9",
"@nestjs/apollo": "^10.1.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
Expand All @@ -33,6 +34,7 @@
"@ngrx/store": "^14.3.1",
"@nrwl/angular": "^14.7.11",
"@nrwl/nest": "^14.7.11",
"apollo-angular": "^4.0.1",
"apollo-server-express": "^3.10.2",
"graphql": "^16.6.0",
"reflect-metadata": "^0.1.13",
Expand All @@ -50,6 +52,7 @@
"@angular/language-service": "~14.2.0",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@graphql-eslint/eslint-plugin": "^3.10.7",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@ngrx/store-devtools": "^14.3.1",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2017", "dom"],
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
Expand Down
Loading

0 comments on commit 73e4d19

Please sign in to comment.