Utilisation d'un serveur Go custom pour le backend au lieu de

super-graph

Malheureusement, super-graph n'a pas tenu les promesses qu'il semblait
annoncer.

Je propose donc de basculer sur un serveur Go classique (via goweb).
L'authentification OpenID Connect étant gérée côté backend et non plus
côté frontend.
This commit is contained in:
2020-07-10 18:07:41 +02:00
parent ff70a6d570
commit 1120474ad9
65 changed files with 880 additions and 848 deletions

43
client/src/util/daddy.ts Normal file
View File

@ -0,0 +1,43 @@
import { GraphQLClient } from 'graphql-request'
import { Config } from "../config";
export class UnauthorizedError extends Error {
constructor(...args: any[]) {
super(...args)
Object.setPrototypeOf(this, UnauthorizedError.prototype);
}
}
export class DaddyClient {
gql: GraphQLClient
constructor(endpoint: string) {
this.gql = new GraphQLClient(endpoint, {
headers: {
mode: 'cors',
}
});
}
fetchUser(email: string) {
return this.gql.rawRequest(`
query fetchUser {
user(where: {email: {eq: $email}}) {
id
created_at
updated_at
email,
full_name
}
}
`, { email })
.then(this.assertAuthorization)
}
assertAuthorization({ status, data }: any) {
if (status === 401) return Promise.reject(new UnauthorizedError());
return data;
}
}