commit working state
Too many changes to split them up. This commit contains roughly two months worth of work. This commit introduces the first aggregate and rewrites the ticket system to follow DDD patterns. It adds Spartan NG as the new component library. TanStack Query to replace GraphQL. Oh and Prisma is almost over as well.
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import { ApplicationConfig, inject } from '@angular/core';
|
||||
import { ApolloClientOptions, InMemoryCache, split } from '@apollo/client/core';
|
||||
import {
|
||||
ApolloClientOptions,
|
||||
ApolloLink,
|
||||
InMemoryCache,
|
||||
split,
|
||||
} from '@apollo/client/core';
|
||||
import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
|
||||
import { getMainDefinition } from '@apollo/client/utilities';
|
||||
import { Apollo, APOLLO_OPTIONS } from 'apollo-angular';
|
||||
import { provideApollo } from 'apollo-angular';
|
||||
import { HttpLink } from 'apollo-angular/http';
|
||||
import { OperationDefinitionNode } from 'graphql';
|
||||
import { createClient } from 'graphql-ws';
|
||||
import { environment } from '../environments/environment';
|
||||
|
||||
const uri = environment.graphQl.endpoint; // <-- add the URL of the GraphQL server here
|
||||
export function apolloOptionsFactory(): ApolloClientOptions<any> {
|
||||
export function apolloOptionsFactory(): ApolloClientOptions {
|
||||
const httpLink = inject(HttpLink);
|
||||
|
||||
const http = httpLink.create({ uri });
|
||||
@@ -17,18 +22,18 @@ export function apolloOptionsFactory(): ApolloClientOptions<any> {
|
||||
const ws = new GraphQLWsLink(
|
||||
createClient({
|
||||
url: environment.graphQl.ws,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const link = split(
|
||||
({ query }) => {
|
||||
const { kind, operation } = getMainDefinition(
|
||||
query
|
||||
query,
|
||||
) as OperationDefinitionNode;
|
||||
return kind === 'OperationDefinition' && operation === 'subscription';
|
||||
},
|
||||
ws,
|
||||
http
|
||||
http,
|
||||
);
|
||||
return {
|
||||
link,
|
||||
@@ -37,9 +42,35 @@ export function apolloOptionsFactory(): ApolloClientOptions<any> {
|
||||
}
|
||||
|
||||
export const graphqlProvider: ApplicationConfig['providers'] = [
|
||||
Apollo,
|
||||
{
|
||||
provide: APOLLO_OPTIONS,
|
||||
useFactory: apolloOptionsFactory,
|
||||
},
|
||||
provideApollo(() => {
|
||||
const httpLink = inject(HttpLink);
|
||||
|
||||
const http = httpLink.create({ uri });
|
||||
|
||||
const ws = new GraphQLWsLink(
|
||||
createClient({
|
||||
url: environment.graphQl.ws,
|
||||
}),
|
||||
);
|
||||
|
||||
const link = ApolloLink.split(
|
||||
({ query }) => {
|
||||
const { kind, operation } = getMainDefinition(
|
||||
query,
|
||||
) as OperationDefinitionNode;
|
||||
return kind === 'OperationDefinition' && operation === 'subscription';
|
||||
},
|
||||
ws,
|
||||
http,
|
||||
);
|
||||
return {
|
||||
link,
|
||||
cache: new InMemoryCache(),
|
||||
};
|
||||
}),
|
||||
// Apollo,
|
||||
// {
|
||||
// provide: APOLLO_OPTIONS,
|
||||
// useFactory: apolloOptionsFactory,
|
||||
// },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user