From 689edac83ef43b41d21fd970aa24d07b255135e6 Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Thu, 21 Apr 2022 00:29:09 +0400 Subject: [PATCH] cleanup: more graphql, remove rest --- src/pages/api/all-forecasts.ts | 13 ------------- src/pages/api/notes.md | 15 --------------- src/pages/dashboards/embed/[id].tsx | 1 + src/pages/dashboards/index.tsx | 5 ++--- src/pages/dashboards/view/[id].tsx | 1 + src/web/display/DashboardCreator.tsx | 6 ++++-- 6 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 src/pages/api/all-forecasts.ts delete mode 100644 src/pages/api/notes.md diff --git a/src/pages/api/all-forecasts.ts b/src/pages/api/all-forecasts.ts deleted file mode 100644 index f10c55e..0000000 --- a/src/pages/api/all-forecasts.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { NextApiRequest, NextApiResponse } from "next/types"; - -import { getFrontpageFull } from "../../backend/frontpage"; - -export default async function handler( - req: NextApiRequest, - res: NextApiResponse -) { - let frontpageFull = await getFrontpageFull(); - console.log(frontpageFull.map((element) => element.title).slice(0, 5)); - console.log("..."); - res.status(200).json(frontpageFull); -} diff --git a/src/pages/api/notes.md b/src/pages/api/notes.md deleted file mode 100644 index 466857d..0000000 --- a/src/pages/api/notes.md +++ /dev/null @@ -1,15 +0,0 @@ -# Metaforecast API - -Modelled roughly after the [Manifold Markets API.](https://manifoldmarkets.notion.site/Manifold-Markets-API-5e7d0aef4dcf452bb04b319e178fabc5). Much as theirs, the metaforecast API is also in alpha. It has at various points been - -## List out all markets - -## Get markets for one particular platform - -## Get history - -Not yet implemented - -// - -https://nextjs.org/docs/messages/api-routes-response-size-limit diff --git a/src/pages/dashboards/embed/[id].tsx b/src/pages/dashboards/embed/[id].tsx index be031e5..8be104c 100644 --- a/src/pages/dashboards/embed/[id].tsx +++ b/src/pages/dashboards/embed/[id].tsx @@ -29,6 +29,7 @@ export const getServerSideProps: GetServerSideProps = async ( return { props: { + // reduntant: page component doesn't do graphql requests, but it's still nice/more consistent to have data in cache urqlState: ssrCache.extractData(), dashboard, numCols: !numCols ? null : numCols < 5 ? numCols : 4, diff --git a/src/pages/dashboards/index.tsx b/src/pages/dashboards/index.tsx index c90e332..b92f00c 100644 --- a/src/pages/dashboards/index.tsx +++ b/src/pages/dashboards/index.tsx @@ -14,7 +14,7 @@ const DashboardsPage: NextPage = () => { ); const handleSubmit = async (data: any) => { - await createDashboard({ + const result = await createDashboard({ input: { title: data.title, description: data.description, @@ -22,8 +22,7 @@ const DashboardsPage: NextPage = () => { ids: data.ids, }, }); - console.log(createDashboardResult); - const dashboardId = createDashboardResult?.data?.result?.dashboard?.id; + const dashboardId = result?.data?.result?.dashboard?.id; if (!dashboardId) { throw new Error("Couldn't create a dashboard"); // TODO - toaster } diff --git a/src/pages/dashboards/view/[id].tsx b/src/pages/dashboards/view/[id].tsx index e3f83af..fa41944 100644 --- a/src/pages/dashboards/view/[id].tsx +++ b/src/pages/dashboards/view/[id].tsx @@ -31,6 +31,7 @@ export const getServerSideProps: GetServerSideProps = async ( return { props: { + // reduntant: page component doesn't do graphql requests, but it's still nice/more consistent to have data in cache urqlState: ssrCache.extractData(), dashboard, }, diff --git a/src/web/display/DashboardCreator.tsx b/src/web/display/DashboardCreator.tsx index 6f49191..133726c 100644 --- a/src/web/display/DashboardCreator.tsx +++ b/src/web/display/DashboardCreator.tsx @@ -60,8 +60,10 @@ Your old input was: ${value}`; You can find the necessary ids by toggling the advanced options in the - search, or by visiting{" "} - /api/all-forecasts + search, or by using{" "} + + GraphQL API +