cleanup: more graphql, remove rest

This commit is contained in:
Vyacheslav Matyukhin 2022-04-21 00:29:09 +04:00
parent 5f56ebf880
commit 689edac83e
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
6 changed files with 8 additions and 33 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -29,6 +29,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
return { return {
props: { props: {
// reduntant: page component doesn't do graphql requests, but it's still nice/more consistent to have data in cache
urqlState: ssrCache.extractData(), urqlState: ssrCache.extractData(),
dashboard, dashboard,
numCols: !numCols ? null : numCols < 5 ? numCols : 4, numCols: !numCols ? null : numCols < 5 ? numCols : 4,

View File

@ -14,7 +14,7 @@ const DashboardsPage: NextPage = () => {
); );
const handleSubmit = async (data: any) => { const handleSubmit = async (data: any) => {
await createDashboard({ const result = await createDashboard({
input: { input: {
title: data.title, title: data.title,
description: data.description, description: data.description,
@ -22,8 +22,7 @@ const DashboardsPage: NextPage = () => {
ids: data.ids, ids: data.ids,
}, },
}); });
console.log(createDashboardResult); const dashboardId = result?.data?.result?.dashboard?.id;
const dashboardId = createDashboardResult?.data?.result?.dashboard?.id;
if (!dashboardId) { if (!dashboardId) {
throw new Error("Couldn't create a dashboard"); // TODO - toaster throw new Error("Couldn't create a dashboard"); // TODO - toaster
} }

View File

@ -31,6 +31,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
return { return {
props: { props: {
// reduntant: page component doesn't do graphql requests, but it's still nice/more consistent to have data in cache
urqlState: ssrCache.extractData(), urqlState: ssrCache.extractData(),
dashboard, dashboard,
}, },

View File

@ -60,8 +60,10 @@ Your old input was: ${value}`;
<InfoBox> <InfoBox>
You can find the necessary ids by toggling the advanced options in the You can find the necessary ids by toggling the advanced options in the
search, or by visiting{" "} search, or by using{" "}
<a href="/api/all-forecasts">/api/all-forecasts</a> <a href="/api/graphql?query=%7B%0A++questions%28first%3A+100%29+%7B%0A++++pageInfo+%7B%0A++++++hasNextPage%0A++++++endCursor%0A++++%7D%0A++++edges+%7B%0A++++++node+%7B%0A++++++++id%0A++++++++title%0A++++++++url%0A++++++%7D%0A++++%7D%0A++%7D%0A%7D">
GraphQL API
</a>
</InfoBox> </InfoBox>
</div> </div>
</form> </form>