@@ -83,7 +83,7 @@ const errorLink = onError(
|
||||
graphQLErrors.map(
|
||||
(graphQLError: GraphQLError & { status_code?: number }) => {
|
||||
if (graphQLError?.status_code !== 401) {
|
||||
console.log(
|
||||
console.debug(
|
||||
`[GraphQL error]: Message: ${graphQLError.message}, Location: ${graphQLError.locations}, Path: ${graphQLError.path}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,22 +6,35 @@ import { authMiddleware } from "./auth";
|
||||
import errorLink from "./error-link";
|
||||
import { uploadLink } from "./absinthe-upload-socket-link";
|
||||
|
||||
// const link = split(
|
||||
// // split based on operation type
|
||||
// ({ query }) => {
|
||||
// const definition = getMainDefinition(query);
|
||||
// return (
|
||||
// definition.kind === "OperationDefinition" &&
|
||||
// definition.operation === "subscription"
|
||||
// );
|
||||
// },
|
||||
// absintheSocketLink,
|
||||
// uploadLink
|
||||
// );
|
||||
let link;
|
||||
|
||||
// The Absinthe socket Apollo link relies on an old library
|
||||
// (@jumpn/utils-composite) which itself relies on an old
|
||||
// Babel version, which is incompatible with Histoire.
|
||||
// We just don't use the absinthe apollo socket link
|
||||
// in this case.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
if (!import.meta.env.VITE_HISTOIRE_ENV) {
|
||||
// const absintheSocketLink = await import("./absinthe-socket-link");
|
||||
|
||||
link = split(
|
||||
// split based on operation type
|
||||
({ query }) => {
|
||||
const definition = getMainDefinition(query);
|
||||
return (
|
||||
definition.kind === "OperationDefinition" &&
|
||||
definition.operation === "subscription"
|
||||
);
|
||||
},
|
||||
absintheSocketLink,
|
||||
uploadLink
|
||||
);
|
||||
}
|
||||
|
||||
const retryLink = new RetryLink();
|
||||
|
||||
export const fullLink = authMiddleware
|
||||
.concat(retryLink)
|
||||
.concat(errorLink)
|
||||
.concat(uploadLink);
|
||||
.concat(link ?? uploadLink);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Resolvers } from "@apollo/client/core/types";
|
||||
export default function buildCurrentUserResolver(
|
||||
cache: ApolloCache<NormalizedCacheObject>
|
||||
): Resolvers {
|
||||
cache.writeQuery({
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_USER_CLIENT,
|
||||
data: {
|
||||
currentUser: {
|
||||
@@ -21,7 +21,7 @@ export default function buildCurrentUserResolver(
|
||||
},
|
||||
});
|
||||
|
||||
cache.writeQuery({
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_ACTOR_CLIENT,
|
||||
data: {
|
||||
currentActor: {
|
||||
@@ -34,7 +34,7 @@ export default function buildCurrentUserResolver(
|
||||
},
|
||||
});
|
||||
|
||||
cache.writeQuery({
|
||||
cache?.writeQuery({
|
||||
query: CURRENT_USER_LOCATION_CLIENT,
|
||||
data: {
|
||||
currentUserLocation: {
|
||||
@@ -70,8 +70,6 @@ export default function buildCurrentUserResolver(
|
||||
},
|
||||
};
|
||||
|
||||
console.debug("updating current user", data);
|
||||
|
||||
localCache.writeQuery({ data, query: CURRENT_USER_CLIENT });
|
||||
},
|
||||
updateCurrentActor: (
|
||||
|
||||
@@ -73,6 +73,9 @@ export const typePolicies: TypePolicies = {
|
||||
Config: {
|
||||
merge: true,
|
||||
},
|
||||
Address: {
|
||||
keyFields: ["id"],
|
||||
},
|
||||
RootQueryType: {
|
||||
fields: {
|
||||
relayFollowers: paginatedLimitPagination<IFollower>(),
|
||||
@@ -110,7 +113,7 @@ export async function refreshAccessToken(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
console.log("Refreshing access token.");
|
||||
console.debug("Refreshing access token.");
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const { mutate, onDone, onError } = provideApolloClient(apolloClient)(() =>
|
||||
@@ -130,7 +133,7 @@ export async function refreshAccessToken(): Promise<boolean> {
|
||||
});
|
||||
|
||||
onError((err) => {
|
||||
console.debug("Failed to refresh token");
|
||||
console.debug("Failed to refresh token", err);
|
||||
reject(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user