Created
May 17, 2024 12:14
Revisions
-
sibelius created this gist
May 17, 2024 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ export const metabaseEmbedResolver = { metabaseEmbedUrl: { type: GraphQLString, args: { question: { type: new GraphQLNonNull(GraphQLString), }, params: { type: GraphQLString, }, }, resolve: (obj, args, context) => { if (!isLoggedIn(context)) { return NullConnection; } const payload = { resource: { question: parseInt(args.question, 10) }, params: args.params ? JSON.parse(args.params) : {}, exp: Math.round(Date.now() / 1000) + 10 * 60, // 10 minute expiration }; const token = jwt.sign(payload, METABASE_SECRET_KEY); const iframeUrl = `${METABASE_SITE_URL }/embed/question/${ token }#bordered=true&titled=true`; return iframeUrl; }, }, };