From a19f405e53281c9ad1fe4b6f021aaf2627b772dc Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Tue, 29 Aug 2023 16:50:44 +0200 Subject: [PATCH] graphql: Expose the BrowserSession User-Agent --- crates/graphql/src/model/browser_sessions.rs | 5 +++++ frontend/schema.graphql | 4 ++++ frontend/src/gql/graphql.ts | 2 ++ frontend/src/gql/schema.ts | 8 ++++++++ 4 files changed, 19 insertions(+) diff --git a/crates/graphql/src/model/browser_sessions.rs b/crates/graphql/src/model/browser_sessions.rs index e07249c7..ad1e6db0 100644 --- a/crates/graphql/src/model/browser_sessions.rs +++ b/crates/graphql/src/model/browser_sessions.rs @@ -87,6 +87,11 @@ impl BrowserSession { BrowserSessionState::Active } } + + /// The user-agent string with which the session was created. + pub async fn user_agent(&self) -> Option<&str> { + self.0.user_agent.as_deref() + } } /// An authentication records when a user enter their credential in a browser diff --git a/frontend/schema.graphql b/frontend/schema.graphql index 478981cd..821534e3 100644 --- a/frontend/schema.graphql +++ b/frontend/schema.graphql @@ -95,6 +95,10 @@ type BrowserSession implements Node & CreationEvent { The state of the session. """ state: BrowserSessionState! + """ + The user-agent string with which the session was created. + """ + userAgent: String } type BrowserSessionConnection { diff --git a/frontend/src/gql/graphql.ts b/frontend/src/gql/graphql.ts index de462da6..2b39fb92 100644 --- a/frontend/src/gql/graphql.ts +++ b/frontend/src/gql/graphql.ts @@ -100,6 +100,8 @@ export type BrowserSession = CreationEvent & state: BrowserSessionState; /** The user logged in this session. */ user: User; + /** The user-agent string with which the session was created. */ + userAgent?: Maybe; }; export type BrowserSessionConnection = { diff --git a/frontend/src/gql/schema.ts b/frontend/src/gql/schema.ts index aa6ab818..e5d546ab 100644 --- a/frontend/src/gql/schema.ts +++ b/frontend/src/gql/schema.ts @@ -172,6 +172,14 @@ export default { }, args: [], }, + { + name: "userAgent", + type: { + kind: "SCALAR", + name: "Any", + }, + args: [], + }, ], interfaces: [ {