diff --git a/docs/graphql.md b/docs/graphql.md index 6e8b914..e6a142e 100644 --- a/docs/graphql.md +++ b/docs/graphql.md @@ -24,6 +24,14 @@ List of all files used for graphql: `graphql-code-generator` converts those into `*.generated.ts` files which can be imported from the React components. +# Notes on caching + +`urql` has both [document caching](https://formidable.com/open-source/urql/docs/basics/document-caching/) and [normalized caching](https://formidable.com/open-source/urql/docs/graphcache/normalized-caching/) (which we don't use yet). + +Unfortunately, it's useful only on a page level: since we like server-side rendering, we still have to hit `getServerSideProps` on navigation, even if we have data in cache. + +There are some possible workaround for this to make client-side navigation faster, but none of them are trivial to implement; relevant Next.js discussion to follow: https://github.com/vercel/next.js/discussions/19611 + # Recipes **I want to check out what Metaforecast's GraphQL API is capable of** diff --git a/prisma/migrations/20220425220646_history_relation/migration.sql b/prisma/migrations/20220425220646_history_relation/migration.sql new file mode 100644 index 0000000..dd2a023 --- /dev/null +++ b/prisma/migrations/20220425220646_history_relation/migration.sql @@ -0,0 +1,5 @@ +ALTER TABLE "history" ADD COLUMN "idref" TEXT; + +ALTER TABLE "history" ADD CONSTRAINT "history_idref_fkey" FOREIGN KEY ("idref") REFERENCES "questions"("id") ON DELETE SET NULL ON UPDATE RESTRICT; + +UPDATE "history" SET idref = id WHERE id in (SELECT id FROM "questions"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9b5a035..0cc5a28 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,5 +1,6 @@ generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + previewFeatures = ["interactiveTransactions"] } generator pothos { @@ -25,15 +26,17 @@ model Dashboard { model History { id String + idref String? + question Question? @relation(fields: [idref], references: [id], onDelete: SetNull, onUpdate: Restrict) title String url String platform String description String options Json - timestamp DateTime @db.Timestamp(6) + timestamp DateTime @db.Timestamp(6) qualityindicators Json extra Json - pk Int @id @default(autoincrement()) + pk Int @id @default(autoincrement()) @@index([id]) @@map("history") @@ -75,6 +78,8 @@ model Question { extra Json onFrontpage FrontpageId? + history History[] + @@map("questions") } diff --git a/schema.graphql b/schema.graphql index 87ced19..bf61eab 100644 --- a/schema.graphql +++ b/schema.graphql @@ -93,6 +93,9 @@ type Query { """Get a list of questions that are currently on the frontpage""" frontpage: [Question!]! + + """Look up a single question by its id""" + question(id: ID!): Question! questions(after: String, before: String, first: Int, last: Int): QueryQuestionsConnection! """ diff --git a/src/backend/flow/history/updateHistory.ts b/src/backend/flow/history/updateHistory.ts index 88aea20..8b56de3 100644 --- a/src/backend/flow/history/updateHistory.ts +++ b/src/backend/flow/history/updateHistory.ts @@ -3,6 +3,9 @@ import { prisma } from "../../database/prisma"; export async function updateHistory() { const questions = await prisma.question.findMany({}); await prisma.history.createMany({ - data: questions, + data: questions.map((q) => ({ + ...q, + idref: q.id, + })), }); } diff --git a/src/backend/platforms/index.ts b/src/backend/platforms/index.ts index dc26bd7..2f6e6f6 100644 --- a/src/backend/platforms/index.ts +++ b/src/backend/platforms/index.ts @@ -89,27 +89,69 @@ export const processPlatform = async (platform: Platform) => { console.log(`Platform ${platform.name} doesn't have a fetcher, skipping`); return; } - const results = await platform.fetcher(); - if (results && results.length) { - await prisma.$transaction([ - prisma.question.deleteMany({ - where: { - platform: platform.name, - }, - }), - prisma.question.createMany({ - data: results.map((q) => ({ - extra: {}, - timestamp: new Date(), - ...q, - qualityindicators: q.qualityindicators as object, // fighting typescript - })), - }), - ]); - console.log("Done"); - } else { + const fetchedQuestions = await platform.fetcher(); + if (!fetchedQuestions || !fetchedQuestions.length) { console.log(`Platform ${platform.name} didn't return any results`); + return; } + + const prepareQuestion = (q: FetchedQuestion): Question => { + return { + extra: {}, + timestamp: new Date(), + ...q, + platform: platform.name, + qualityindicators: q.qualityindicators as object, // fighting typescript + }; + }; + + const oldQuestions = await prisma.question.findMany({ + where: { + platform: platform.name, + }, + }); + + const fetchedIds = fetchedQuestions.map((q) => q.id); + const oldIds = oldQuestions.map((q) => q.id); + + const fetchedIdsSet = new Set(fetchedIds); + const oldIdsSet = new Set(oldIds); + + const createdQuestions: Question[] = []; + const updatedQuestions: Question[] = []; + const deletedIds = oldIds.filter((id) => !fetchedIdsSet.has(id)); + + for (const q of fetchedQuestions.map((q) => prepareQuestion(q))) { + if (oldIdsSet.has(q.id)) { + updatedQuestions.push(q); + } else { + // TODO - check if question has changed for better performance + createdQuestions.push(q); + } + } + + await prisma.question.createMany({ + data: createdQuestions, + }); + + for (const q of updatedQuestions) { + await prisma.question.update({ + where: { id: q.id }, + data: q, + }); + } + + await prisma.question.deleteMany({ + where: { + id: { + in: deletedIds, + }, + }, + }); + + console.log( + `Done, ${deletedIds.length} deleted, ${updatedQuestions.length} updated, ${createdQuestions.length} created` + ); }; export interface PlatformConfig { diff --git a/src/backend/platforms/xrisk.ts b/src/backend/platforms/xrisk.ts index e4affaf..c769ae9 100644 --- a/src/backend/platforms/xrisk.ts +++ b/src/backend/platforms/xrisk.ts @@ -15,11 +15,15 @@ export const xrisk: Platform = { encoding: "utf-8", }); let results = JSON.parse(fileRaw); - results = results.map((item) => ({ - ...item, - id: `${platformName}-${hash(item.title + " | " + item.url)}`, // some titles are non-unique, but title+url pair is always unique - platform: platformName, - })); + results = results.map((item) => { + item.extra = item.moreoriginsdata; + delete item.moreoriginsdata; + return { + ...item, + id: `${platformName}-${hash(item.title + " | " + item.url)}`, // some titles are non-unique, but title+url pair is always unique + platform: platformName, + }; + }); return results; }, }; diff --git a/src/graphql/introspection.json b/src/graphql/introspection.json index b61e76f..2e63eab 100644 --- a/src/graphql/introspection.json +++ b/src/graphql/introspection.json @@ -1 +1 @@ -{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"SCALAR","name":"Boolean","description":"The `Boolean` scalar type represents `true` or `false`.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"CreateDashboardInput","description":null,"fields":null,"inputFields":[{"name":"creator","description":"The creator of the dashboard, e.g. \"Peter Parker\"","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"description","description":"The longer description of the dashboard","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"ids","description":"List of question ids","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}}}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"title","description":"The title of the dashboard","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"CreateDashboardResult","description":null,"fields":[{"name":"dashboard","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Dashboard","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Dashboard","description":null,"fields":[{"name":"creator","description":"The creator of the dashboard, e.g. \"Peter Parker\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":"The longer description of the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"questions","description":"The list of questions on the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"title","description":"The title of the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Date","description":"Date serialized as the Unix timestamp.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Float","description":"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"ID","description":"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Mutation","description":null,"fields":[{"name":"createDashboard","description":"Create a new dashboard; if the dashboard with given ids already exists then it will be returned instead.","args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"CreateDashboardInput","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"CreateDashboardResult","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"PageInfo","description":null,"fields":[{"name":"endCursor","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"hasNextPage","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"hasPreviousPage","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"startCursor","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Platform","description":"Forecasting platform supported by Metaforecast","fields":[{"name":"id","description":"Short unique platform name, e.g. \"xrisk\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"label","description":"Platform name for displaying on frontend etc., e.g. \"X-risk estimates\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"ProbabilityOption","description":null,"fields":[{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"probability","description":"0 to 1","args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QualityIndicators","description":"Various indicators of the question's quality","fields":[{"name":"liquidity","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"numForecasters","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"numForecasts","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"openInterest","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"sharesVolume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"spread","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"stars","description":"0 to 5","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"tradeVolume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"volume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Query","description":null,"fields":[{"name":"dashboard","description":"Look up a single dashboard by its id","args":[{"name":"id","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Dashboard","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"frontpage","description":"Get a list of questions that are currently on the frontpage","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"questions","description":null,"args":[{"name":"after","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"before","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"first","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"last","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"QueryQuestionsConnection","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"searchQuestions","description":"Search for questions; uses Algolia instead of the primary metaforecast database","args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"SearchInput","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QueryQuestionsConnection","description":null,"fields":[{"name":"edges","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"QueryQuestionsConnectionEdge","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"pageInfo","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"PageInfo","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QueryQuestionsConnectionEdge","description":null,"fields":[{"name":"cursor","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"node","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Question","description":null,"fields":[{"name":"description","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"Unique string which identifies the question","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"options","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"ProbabilityOption","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"platform","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Platform","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"qualityIndicators","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"QualityIndicators","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"timestamp","description":"Timestamp at which metaforecast fetched the question","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Date","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"title","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"url","description":"Non-unique, a very small number of platforms have a page for more than one prediction","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"visualization","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"SearchInput","description":null,"fields":null,"inputFields":[{"name":"forecastingPlatforms","description":"List of platform ids to filter by","type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"forecastsThreshold","description":"Minimum number of forecasts on a question","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"limit","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"query","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"starsThreshold","description":"Minimum number of stars on a question","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isRepeatable","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"VARIABLE_DEFINITION","description":"Location adjacent to a variable definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server support subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"specifiedByURL","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given `__Type` is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. `fields` and `interfaces` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. `possibleTypes` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. `enumValues` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. `inputFields` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null}],"directives":[{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","isRepeatable":false,"locations":["ARGUMENT_DEFINITION","ENUM_VALUE","FIELD_DEFINITION","INPUT_FIELD_DEFINITION"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\"No longer supported\"","isDeprecated":false,"deprecationReason":null}]},{"name":"include","description":"Directs the executor to include this field or fragment only when the `if` argument is true.","isRepeatable":false,"locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]},{"name":"skip","description":"Directs the executor to skip this field or fragment when the `if` argument is true.","isRepeatable":false,"locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]},{"name":"specifiedBy","description":"Exposes a URL that specifies the behavior of this scalar.","isRepeatable":false,"locations":["SCALAR"],"args":[{"name":"url","description":"The URL that specifies the behavior of this scalar.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]}]}} \ No newline at end of file +{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"SCALAR","name":"Boolean","description":"The `Boolean` scalar type represents `true` or `false`.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"CreateDashboardInput","description":null,"fields":null,"inputFields":[{"name":"creator","description":"The creator of the dashboard, e.g. \"Peter Parker\"","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"description","description":"The longer description of the dashboard","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"ids","description":"List of question ids","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}}}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"title","description":"The title of the dashboard","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"CreateDashboardResult","description":null,"fields":[{"name":"dashboard","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Dashboard","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Dashboard","description":null,"fields":[{"name":"creator","description":"The creator of the dashboard, e.g. \"Peter Parker\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":"The longer description of the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"questions","description":"The list of questions on the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"title","description":"The title of the dashboard","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Date","description":"Date serialized as the Unix timestamp.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Float","description":"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"ID","description":"The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Mutation","description":null,"fields":[{"name":"createDashboard","description":"Create a new dashboard; if the dashboard with given ids already exists then it will be returned instead.","args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"CreateDashboardInput","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"CreateDashboardResult","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"PageInfo","description":null,"fields":[{"name":"endCursor","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"hasNextPage","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"hasPreviousPage","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"startCursor","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Platform","description":"Forecasting platform supported by Metaforecast","fields":[{"name":"id","description":"Short unique platform name, e.g. \"xrisk\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"label","description":"Platform name for displaying on frontend etc., e.g. \"X-risk estimates\"","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"ProbabilityOption","description":null,"fields":[{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"probability","description":"0 to 1","args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QualityIndicators","description":"Various indicators of the question's quality","fields":[{"name":"liquidity","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"numForecasters","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"numForecasts","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"openInterest","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"sharesVolume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"spread","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"stars","description":"0 to 5","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Int","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"tradeVolume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"volume","description":null,"args":[],"type":{"kind":"SCALAR","name":"Float","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Query","description":null,"fields":[{"name":"dashboard","description":"Look up a single dashboard by its id","args":[{"name":"id","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Dashboard","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"frontpage","description":"Get a list of questions that are currently on the frontpage","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"question","description":"Look up a single question by its id","args":[{"name":"id","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"questions","description":null,"args":[{"name":"after","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"before","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"first","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"last","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"QueryQuestionsConnection","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"searchQuestions","description":"Search for questions; uses Algolia instead of the primary metaforecast database","args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"SearchInput","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QueryQuestionsConnection","description":null,"fields":[{"name":"edges","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"QueryQuestionsConnectionEdge","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"pageInfo","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"PageInfo","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"QueryQuestionsConnectionEdge","description":null,"fields":[{"name":"cursor","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"node","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Question","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Question","description":null,"fields":[{"name":"description","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"Unique string which identifies the question","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"options","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"ProbabilityOption","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"platform","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"Platform","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"qualityIndicators","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"QualityIndicators","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"timestamp","description":"Timestamp at which metaforecast fetched the question","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Date","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"title","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"url","description":"Non-unique, a very small number of platforms have a page for more than one prediction","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"visualization","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"SearchInput","description":null,"fields":null,"inputFields":[{"name":"forecastingPlatforms","description":"List of platform ids to filter by","type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"forecastsThreshold","description":"Minimum number of forecasts on a question","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"limit","description":null,"type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"query","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null},{"name":"starsThreshold","description":"Minimum number of stars on a question","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.","fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isRepeatable","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"VARIABLE_DEFINITION","description":"Location adjacent to a variable definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server support subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"specifiedByURL","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false","isDeprecated":false,"deprecationReason":null}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given `__Type` is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. `fields` and `interfaces` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. `possibleTypes` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. `enumValues` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. `inputFields` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. `ofType` is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null}],"directives":[{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","isRepeatable":false,"locations":["ARGUMENT_DEFINITION","ENUM_VALUE","FIELD_DEFINITION","INPUT_FIELD_DEFINITION"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\"No longer supported\"","isDeprecated":false,"deprecationReason":null}]},{"name":"include","description":"Directs the executor to include this field or fragment only when the `if` argument is true.","isRepeatable":false,"locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]},{"name":"skip","description":"Directs the executor to skip this field or fragment when the `if` argument is true.","isRepeatable":false,"locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]},{"name":"specifiedBy","description":"Exposes a URL that specifies the behavior of this scalar.","isRepeatable":false,"locations":["SCALAR"],"args":[{"name":"url","description":"The URL that specifies the behavior of this scalar.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"defaultValue":null,"isDeprecated":false,"deprecationReason":null}]}]}} \ No newline at end of file diff --git a/src/graphql/schema/questions.ts b/src/graphql/schema/questions.ts index bec5f29..cb33bcd 100644 --- a/src/graphql/schema/questions.ts +++ b/src/graphql/schema/questions.ts @@ -1,3 +1,5 @@ +import { History, Question } from "@prisma/client"; + import { prisma } from "../../backend/database/prisma"; import { platforms, QualityIndicators } from "../../backend/platforms"; import { builder } from "../builder"; @@ -78,44 +80,67 @@ export const ProbabilityOptionObj = builder }), }); +const QuestionShapeInterface = builder + .interfaceRef("QuestionShape") + .implement({ + fields: (t) => ({ + title: t.exposeString("title"), + description: t.exposeString("description"), + url: t.exposeString("url", { + description: + "Non-unique, a very small number of platforms have a page for more than one prediction", + }), + platform: t.field({ + type: PlatformObj, + resolve: (parent) => parent.platform, + }), + timestamp: t.field({ + type: "Date", + description: "Timestamp at which metaforecast fetched the question", + resolve: (parent) => parent.timestamp, + }), + qualityIndicators: t.field({ + type: QualityIndicatorsObj, + resolve: (parent) => + parent.qualityindicators as any as QualityIndicators, + }), + options: t.field({ + type: [ProbabilityOptionObj], + resolve: ({ options }) => { + if (!Array.isArray(options)) { + return []; + } + return options as any[]; + }, + }), + }), + }); + +export const HistoryObj = builder.prismaObject("History", { + findUnique: (history) => ({ pk: history.pk }), + interfaces: [QuestionShapeInterface], + fields: (t) => ({ + id: t.exposeID("pk", { + description: "History items are identified by their integer ids", + }), + questionId: t.exposeID("id", { + description: "Unique string which identifies the question", + }), + }), +}); + export const QuestionObj = builder.prismaObject("Question", { findUnique: (question) => ({ id: question.id }), + interfaces: [QuestionShapeInterface], fields: (t) => ({ id: t.exposeID("id", { description: "Unique string which identifies the question", }), - title: t.exposeString("title"), - description: t.exposeString("description"), - url: t.exposeString("url", { - description: - "Non-unique, a very small number of platforms have a page for more than one prediction", - }), - timestamp: t.field({ - type: "Date", - description: "Timestamp at which metaforecast fetched the question", - resolve: (parent) => parent.timestamp, - }), - platform: t.field({ - type: PlatformObj, - resolve: (parent) => parent.platform, - }), - qualityIndicators: t.field({ - type: QualityIndicatorsObj, - resolve: (parent) => parent.qualityindicators as any as QualityIndicators, - }), - options: t.field({ - type: [ProbabilityOptionObj], - resolve: ({ options }) => { - if (!Array.isArray(options)) { - return []; - } - return options as any[]; - }, - }), visualization: t.string({ resolve: (parent) => (parent.extra as any)?.visualization, // used for guesstimate only, see searchGuesstimate.ts nullable: true, }), + history: t.relation("history", {}), }), }); @@ -125,10 +150,26 @@ builder.queryField("questions", (t) => type: "Question", cursor: "id", maxSize: 1000, - resolve: (query, parent, args, context, info) => - prisma.question.findMany({ ...query }), + resolve: (query) => prisma.question.findMany({ ...query }), }, {}, {} ) ); + +builder.queryField("question", (t) => + t.field({ + type: QuestionObj, + description: "Look up a single question by its id", + args: { + id: t.arg({ type: "ID", required: true }), + }, + resolve: async (parent, args) => { + return await prisma.question.findUnique({ + where: { + id: String(args.id), + }, + }); + }, + }) +); diff --git a/src/graphql/types.generated.ts b/src/graphql/types.generated.ts index 3c6a1c8..e7c2e94 100644 --- a/src/graphql/types.generated.ts +++ b/src/graphql/types.generated.ts @@ -99,6 +99,8 @@ export type Query = { dashboard: Dashboard; /** Get a list of questions that are currently on the frontpage */ frontpage: Array; + /** Look up a single question by its id */ + question: Question; questions: QueryQuestionsConnection; /** Search for questions; uses Algolia instead of the primary metaforecast database */ searchQuestions: Array; @@ -110,6 +112,11 @@ export type QueryDashboardArgs = { }; +export type QueryQuestionArgs = { + id: Scalars['ID']; +}; + + export type QueryQuestionsArgs = { after?: InputMaybe; before?: InputMaybe; diff --git a/src/pages/about.tsx b/src/pages/about.tsx index 193d0fe..4a0a0c7 100644 --- a/src/pages/about.tsx +++ b/src/pages/about.tsx @@ -1,7 +1,9 @@ +import { NextPage } from "next"; import React from "react"; import ReactMarkdown from "react-markdown"; import gfm from "remark-gfm"; +import { Card } from "../web/display/Card"; import { Layout } from "../web/display/Layout"; const readmeMarkdownText = `# About @@ -26,16 +28,16 @@ Also note that, whatever other redeeming features they might have, prediction ma `; -export default function About() { +const AboutPage: NextPage = () => { return ( -
- -
+ +
+ +
+
); -} +}; + +export default AboutPage; diff --git a/src/pages/questions/[id].tsx b/src/pages/questions/[id].tsx new file mode 100644 index 0000000..41ccff7 --- /dev/null +++ b/src/pages/questions/[id].tsx @@ -0,0 +1,4 @@ +export { + default, + getServerSideProps, +} from "../../web/questions/pages/QuestionPage"; diff --git a/src/pages/tools.tsx b/src/pages/tools.tsx index eef031b..7463a07 100644 --- a/src/pages/tools.tsx +++ b/src/pages/tools.tsx @@ -1,3 +1,4 @@ +import { NextPage } from "next"; import Link from "next/link"; import React from "react"; @@ -45,7 +46,7 @@ const ToolCard: React.FC = (tool) => { } }; -export default function Tools({ lastUpdated }) { +const ToolsPage: NextPage = () => { let tools: Tool[] = [ { title: "Search", @@ -87,9 +88,11 @@ export default function Tools({ lastUpdated }) {
{tools.map((tool, i) => ( - + ))}
); -} +}; + +export default ToolsPage; diff --git a/src/web/common/CopyText.tsx b/src/web/common/CopyText.tsx new file mode 100644 index 0000000..856d255 --- /dev/null +++ b/src/web/common/CopyText.tsx @@ -0,0 +1,19 @@ +import { FaRegClipboard } from "react-icons/fa"; + +interface Props { + text: string; + displayText: string; +} + +export const CopyText: React.FC = ({ text, displayText }) => ( +
{ + e.preventDefault(); + navigator.clipboard.writeText(text); + }} + > + {displayText} + +
+); diff --git a/src/web/common/Query.tsx b/src/web/common/Query.tsx new file mode 100644 index 0000000..5f7c649 --- /dev/null +++ b/src/web/common/Query.tsx @@ -0,0 +1,49 @@ +import React from "react"; +import { TypedDocumentNode, useQuery } from "urql"; + +import { Spinner } from "./Spinner"; + +type Props = { + document: TypedDocumentNode; + variables?: Variables; + children: ({ data }: { data: Data }) => React.ReactElement | null; +}; + +export function Query({ + document, + variables, + children, +}: Props): React.ReactElement | null { + const [result] = useQuery({ + query: document, + variables, + }); + + const { data, fetching, error } = result; + + if (fetching) { + return ( +

+ +

+ ); + } + + if (error) { + return ( +

+ Internal error: {error.message} +

+ ); + } + + if (!data) { + return ( +

+ Internal error +

+ ); + } + + return children({ data }); +} diff --git a/src/web/common/Spinner.tsx b/src/web/common/Spinner.tsx new file mode 100644 index 0000000..cf87d26 --- /dev/null +++ b/src/web/common/Spinner.tsx @@ -0,0 +1,22 @@ +// via https://github.com/tailwindlabs/heroicons/issues/131#issuecomment-829192663 +export const Spinner: React.FC = () => ( + + + + +); diff --git a/src/web/display/Card.tsx b/src/web/display/Card.tsx index a77614e..636d739 100644 --- a/src/web/display/Card.tsx +++ b/src/web/display/Card.tsx @@ -2,12 +2,20 @@ const CardTitle: React.FC = ({ children }) => (
{children}
); -type CardType = React.FC & { +interface Props { + highlightOnHover?: boolean; +} + +type CardType = React.FC & { Title: typeof CardTitle; }; -export const Card: CardType = ({ children }) => ( -
+export const Card: CardType = ({ children, highlightOnHover = true }) => ( +
{children}
); diff --git a/src/web/display/DisplayQuestion/QuestionFooter.tsx b/src/web/display/DisplayQuestion/QuestionFooter.tsx index 667d92c..beebe2b 100644 --- a/src/web/display/DisplayQuestion/QuestionFooter.tsx +++ b/src/web/display/DisplayQuestion/QuestionFooter.tsx @@ -3,57 +3,28 @@ import { QuestionFragment } from "../../search/queries.generated"; type QualityIndicator = QuestionFragment["qualityIndicators"]; type IndicatorName = keyof QualityIndicator; -const formatQualityIndicator = (indicator: IndicatorName) => { - let result: string | null = null; - switch (indicator) { - case "numForecasts": - result = null; - break; +// this duplication can probably be simplified with typescript magic, but this is good enough for now +type UsedIndicatorName = + | "volume" + | "numForecasters" + | "spread" + | "sharesVolume" + | "liquidity" + | "tradeVolume" + | "openInterest"; - case "stars": - result = null; - break; - - case "volume": - result = "Volume"; - break; - - case "numForecasters": - result = "Forecasters"; - break; - - // case "yesBid": - // result = null; // "Yes bid" - // break; - - // case "yesAsk": - // result = null; // "Yes ask" - // break; - - case "spread": - result = "Spread"; - break; - case "sharesVolume": - result = "Shares vol."; - break; - - case "openInterest": - result = "Interest"; - break; - - // case "resolution_data": - // result = null; - // break; - - case "liquidity": - result = "Liquidity"; - break; - - case "tradeVolume": - result = "Volume"; - break; - } - return result; +const qualityIndicatorLabels: { [k in UsedIndicatorName]: string } = { + // numForecasts: null, + // stars: null, + // yesBid: "Yes bid", + // yesAsk: "Yes ask", + volume: "Volume", + numForecasters: "Forecasters", + spread: "Spread", + sharesVolume: "Shares vol.", + liquidity: "Liquidity", + tradeVolume: "Volume", + openInterest: "Interest", }; const formatNumber = (num) => { @@ -66,27 +37,16 @@ const formatNumber = (num) => { } }; -const formatQualityIndicators = (qualityIndicators: QualityIndicator) => { - let newQualityIndicators: { [k: string]: string | number } = {}; - for (const key of Object.keys(qualityIndicators)) { - const newKey = formatQualityIndicator(key as IndicatorName); - if (newKey && qualityIndicators[key] !== null) { - newQualityIndicators[newKey] = qualityIndicators[key]; - } - } - return newQualityIndicators; -}; - /* Display functions*/ const getPercentageSymbolIfNeeded = ({ indicator, platform, }: { - indicator: string; + indicator: UsedIndicatorName; platform: string; }) => { - let indicatorsWhichNeedPercentageSymbol = ["Spread"]; + let indicatorsWhichNeedPercentageSymbol: IndicatorName[] = ["spread"]; if (indicatorsWhichNeedPercentageSymbol.includes(indicator)) { return "%"; } else { @@ -98,10 +58,15 @@ const getCurrencySymbolIfNeeded = ({ indicator, platform, }: { - indicator: string; + indicator: UsedIndicatorName; platform: string; }) => { - let indicatorsWhichNeedCurrencySymbol = ["Volume", "Interest", "Liquidity"]; + const indicatorsWhichNeedCurrencySymbol: IndicatorName[] = [ + "volume", + "tradeVolume", + "openInterest", + "liquidity", + ]; let dollarPlatforms = ["predictit", "kalshi", "polymarket"]; if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) { if (dollarPlatforms.includes(platform)) { @@ -114,76 +79,50 @@ const getCurrencySymbolIfNeeded = ({ } }; -const showFirstQualityIndicator = ({ - numforecasts, - lastUpdated, - showTimeStamp, - qualityindicators, -}) => { - if (!!numforecasts) { +const FirstQualityIndicator: React.FC<{ + question: QuestionFragment; +}> = ({ question }) => { + if (question.qualityIndicators.numForecasts) { return ( -
- {/*{` ${numforecasts == 1 ? "Forecast" : "Forecasts:"}`} */} - {"Forecasts:"}  - {Number(numforecasts).toFixed(0)} +
+ Forecasts:  + + {Number(question.qualityIndicators.numForecasts).toFixed(0)} +
); - } else if (showTimeStamp) { - return ( - - - - - {`Last updated: ${ - lastUpdated ? lastUpdated.toISOString().slice(0, 10) : "unknown" - }`} - - ); } else { return null; } }; -const displayQualityIndicators: React.FC<{ - numforecasts: number; - lastUpdated: Date; - showTimeStamp: boolean; - qualityindicators: QuestionFragment["qualityIndicators"]; - platform: string; // id string - e.g. "goodjudgment", not "Good Judgment" -}> = ({ - numforecasts, - lastUpdated, - showTimeStamp, - qualityindicators, - platform, -}) => { - // grid grid-cols-1 +const QualityIndicatorsList: React.FC<{ + question: QuestionFragment; +}> = ({ question }) => { return (
- {showFirstQualityIndicator({ - numforecasts, - lastUpdated, - showTimeStamp, - qualityindicators, + + {Object.entries(question.qualityIndicators).map((entry, i) => { + const indicatorLabel = qualityIndicatorLabels[entry[0]]; + if (!indicatorLabel || entry[1] === null) return; + const indicator = entry[0] as UsedIndicatorName; // guaranteed by the previous line + const value = entry[1]; + + return ( +
+ {indicatorLabel}:  + + {`${getCurrencySymbolIfNeeded({ + indicator, + platform: question.platform.id, + })}${formatNumber(value)}${getPercentageSymbolIfNeeded({ + indicator, + platform: question.platform.id, + })}`} + +
+ ); })} - {Object.entries(formatQualityIndicators(qualityindicators)).map( - (entry, i) => { - return ( -
- {`${entry[0]}:`}  - - {`${getCurrencySymbolIfNeeded({ - indicator: entry[0], - platform, - })}${formatNumber(entry[1])}${getPercentageSymbolIfNeeded({ - indicator: entry[0], - platform, - })}`} - -
- ); - } - )}
); }; @@ -244,30 +183,14 @@ function getStarsColor(numstars: number) { } interface Props { - stars: any; - platform: string; - platformLabel: string; - numforecasts: any; - qualityindicators: QuestionFragment["qualityIndicators"]; - lastUpdated: Date; - showTimeStamp: boolean; + question: QuestionFragment; expandFooterToFullWidth: boolean; } export const QuestionFooter: React.FC = ({ - stars, - platform, - platformLabel, - numforecasts, - qualityindicators, - lastUpdated, - showTimeStamp, + question, expandFooterToFullWidth, }) => { - // I experimented with justify-evenly, justify-around, etc., here: https://tailwindcss.com/docs/justify-content - // I came to the conclusion that as long as the description isn't justified too, aligning the footer symmetrically doesn't make sense - // because the contrast is jarring. - let debuggingWithBackground = false; return (
= ({ } text-gray-500 mb-2 mt-1`} >
- {getstars(stars)} + {getstars(question.qualityIndicators.stars)}
- {platformLabel + {question.platform.label .replace("Good Judgment Open", "GJOpen") .replace(/ /g, "\u00a0")}
@@ -295,15 +218,9 @@ export const QuestionFooter: React.FC = ({ expandFooterToFullWidth ? "justify-self-end mr-4" : "justify-self-center" - } col-span-1 ${debuggingWithBackground ? "bg-red-100" : ""}`} + } col-span-1`} > - {displayQualityIndicators({ - numforecasts, - lastUpdated, - showTimeStamp, - qualityindicators, - platform, - })} +
); diff --git a/src/web/display/DisplayQuestion/index.tsx b/src/web/display/DisplayQuestion/index.tsx index 50967c1..b117207 100644 --- a/src/web/display/DisplayQuestion/index.tsx +++ b/src/web/display/DisplayQuestion/index.tsx @@ -1,6 +1,9 @@ -import { FaRegClipboard } from "react-icons/fa"; +import Link from "next/link"; +import { FaExpand } from "react-icons/fa"; import ReactMarkdown from "react-markdown"; +import { CopyText } from "../../common/CopyText"; +import { QuestionOptions } from "../../questions/components/QuestionOptions"; import { QuestionFragment } from "../../search/queries.generated"; import { Card } from "../Card"; import { QuestionFooter } from "./QuestionFooter"; @@ -12,7 +15,7 @@ const truncateText = (length: number, text: string): string => { if (!!text && text.length <= length) { return text; } - let breakpoints = " .!?"; + const breakpoints = " .!?"; let lastLetter = null; let lastIndex = null; for (let index = length; index > 0; index--) { @@ -29,17 +32,6 @@ const truncateText = (length: number, text: string): string => { return truncatedText; }; -const formatProbability = (probability: number) => { - let percentage = probability * 100; - let percentageCapped = - percentage < 1 - ? "< 1%" - : percentage > 99 - ? "> 99%" - : percentage.toFixed(0) + "%"; - return percentageCapped; -}; - // replaceAll polyfill function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string @@ -94,99 +86,12 @@ const cleanText = (text: string): string => { return textString; }; -const primaryForecastColor = (probability: number) => { - if (probability < 0.03) { - return "bg-red-600"; - } else if (probability < 0.1) { - return "bg-red-600 opacity-80"; - } else if (probability < 0.2) { - return "bg-red-600 opacity-70"; - } else if (probability < 0.3) { - return "bg-red-600 opacity-60"; - } else if (probability < 0.4) { - return "bg-red-600 opacity-50"; - } else if (probability < 0.5) { - return "bg-gray-500"; - } else if (probability < 0.6) { - return "bg-gray-500"; - } else if (probability < 0.7) { - return "bg-green-600 opacity-50"; - } else if (probability < 0.8) { - return "bg-green-600 opacity-60"; - } else if (probability < 0.9) { - return "bg-green-600 opacity-70"; - } else if (probability < 0.97) { - return "bg-green-600 opacity-80"; - } else { - return "bg-green-600"; - } -}; - -const textColor = (probability: number) => { - if (probability < 0.03) { - return "text-red-600"; - } else if (probability < 0.1) { - return "text-red-600 opacity-80"; - } else if (probability < 0.2) { - return "text-red-600 opacity-80"; - } else if (probability < 0.3) { - return "text-red-600 opacity-70"; - } else if (probability < 0.4) { - return "text-red-600 opacity-70"; - } else if (probability < 0.5) { - return "text-gray-500"; - } else if (probability < 0.6) { - return "text-gray-500"; - } else if (probability < 0.7) { - return "text-green-600 opacity-70"; - } else if (probability < 0.8) { - return "text-green-600 opacity-70"; - } else if (probability < 0.9) { - return "text-green-600 opacity-80"; - } else if (probability < 0.97) { - return "text-green-600 opacity-80"; - } else { - return "text-green-600"; - } -}; - -const primaryEstimateAsText = (probability: number) => { - if (probability < 0.03) { - return "Exceptionally unlikely"; - } else if (probability < 0.1) { - return "Very unlikely"; - } else if (probability < 0.4) { - return "Unlikely"; - } else if (probability < 0.6) { - return "About Even"; - } else if (probability < 0.9) { - return "Likely"; - } else if (probability < 0.97) { - return "Very likely"; - } else { - return "Virtually certain"; - } -}; - -// Logical checks - -const checkIfDisplayTimeStampAtBottom = (qualityIndicators: { - [k: string]: any; -}) => { - let indicators = Object.keys(qualityIndicators); - if (indicators.length == 1 && indicators[0] == "stars") { - return true; - } else { - return false; - } -}; - // Auxiliary components const DisplayMarkdown: React.FC<{ description: string }> = ({ description, }) => { - let formatted = truncateText(250, cleanText(description)); + const formatted = truncateText(250, cleanText(description)); // overflow-hidden overflow-ellipsis h-24 return formatted === "" ? null : (
@@ -197,63 +102,6 @@ const DisplayMarkdown: React.FC<{ description: string }> = ({ ); }; -const OptionRow: React.FC<{ option: any }> = ({ option }) => { - const chooseColor = (probability: number) => { - if (probability < 0.1) { - return "bg-blue-50 text-blue-500"; - } else if (probability < 0.3) { - return "bg-blue-100 text-blue-600"; - } else if (probability < 0.7) { - return "bg-blue-200 text-blue-700"; - } else { - return "bg-blue-300 text-blue-800"; - } - }; - - return ( -
-
- {formatProbability(option.probability)} -
-
- {option.name} -
-
- ); -}; - -const ForecastOptions: React.FC<{ options: any[] }> = ({ options }) => { - const optionsSorted = options.sort((a, b) => b.probability - a.probability); - const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options. - return ( -
- {optionsMax5.map((option, i) => ( - - ))} -
- ); -}; - -const CopyText: React.FC<{ text: string; displayText: string }> = ({ - text, - displayText, -}) => ( -
{ - e.preventDefault(); - navigator.clipboard.writeText(text); - }} - > - {displayText} - -
-); - const LastUpdated: React.FC<{ timestamp: Date }> = ({ timestamp }) => (
@@ -276,116 +124,91 @@ interface Props { } export const DisplayQuestion: React.FC = ({ - question: { - id, - title, - url, - platform, - description, - options, - qualityIndicators, - timestamp, - visualization, - }, + question, showTimeStamp, expandFooterToFullWidth, showIdToggle, }) => { - const lastUpdated = new Date(timestamp * 1000); - const displayTimestampAtBottom = - checkIfDisplayTimeStampAtBottom(qualityIndicators); + const { options } = question; + const lastUpdated = new Date(question.timestamp * 1000); - const yesNoOptions = + const isBinary = options.length === 2 && (options[0].name === "Yes" || options[0].name === "No"); return ( - - -
-
- {showIdToggle ? ( -
- -
+ +
+
+ {showIdToggle ? ( +
+ +
+ ) : null} +
+ {process.env.NEXT_PUBLIC_ENABLE_QUESTION_PAGES ? ( + + + + + ) : null} - {title} - {yesNoOptions && ( -
-
- - {formatProbability(options[0].probability)} - - - {primaryEstimateAsText(options[0].probability)} - -
-
- -
-
- )} - {!yesNoOptions && ( -
- -
- -
-
- )} - - {platform.id !== "guesstimate" && options.length < 3 && ( -
- -
- )} - - {platform.id === "guesstimate" && ( - Guesstimate Screenshot - )} + + + {question.title} + +
-
- {/* This one is exclusively for mobile*/} - -
-
- + +
+ +
+
+ ) : ( +
+ +
+ +
+
+ )} + + {question.platform.id !== "guesstimate" && options.length < 3 && ( +
+ +
+ )} + + {question.platform.id === "guesstimate" && ( + Guesstimate Screenshot -
+ )}
-
- +
+ {/* This one is exclusively for mobile*/} + +
+
+ +
+
+ ); }; diff --git a/src/web/display/Layout.tsx b/src/web/display/Layout.tsx index c85e704..6993e90 100644 --- a/src/web/display/Layout.tsx +++ b/src/web/display/Layout.tsx @@ -4,15 +4,32 @@ import React, { ErrorInfo } from "react"; import { Logo2 } from "../icons/index"; -/* Utilities */ -const classNameSelected = (isSelected: boolean) => - `no-underline py-4 px-2 ml-4 text-md font-medium cursor-pointer border-b-2 border-transparent ${ - isSelected - ? "text-blue-700 border-blue-700" - : "text-gray-400 hover:text-blue-500 hover:border-blue-500" - }`; +interface MenuItem { + page: string; + link: string; + title: string; +} -let calculateLastUpdate = () => { +const menu: MenuItem[] = [ + { + page: "search", + link: "/", + title: "Search", + }, + { + page: "tools", + link: "/tools", + title: "Tools", + }, + { + page: "about", + link: "/about", + title: "About", + }, +]; + +/* Utilities */ +const calculateLastUpdate = () => { let today = new Date().toISOString(); let yesterdayObj = new Date(); yesterdayObj.setDate(yesterdayObj.getDate() - 1); @@ -66,26 +83,16 @@ class ErrorBoundary extends React.Component< } } +interface Props { + page: string; // id used for menu +} + /* Main */ -export const Layout = ({ page, children }) => { +export const Layout: React.FC = ({ page, children }) => { let lastUpdated = calculateLastUpdate(); // The correct way to do this would be by passing a prop to Layout, // and to get the last updating using server side props. - const refreshPage = () => { - // window.location.reload(true); - // window.location.replace(window.location.pathname); - // window.location.reload(); - // https://developer.mozilla.org/en-US/docs/Web/API/Location/reload - // https://developer.mozilla.org/en-US/docs/Web/API/Location/replace - // https://developer.mozilla.org/en-US/docs/Web/API/Location/assign - // window.location.hostname - if (typeof window !== "undefined") { - if ((window.location as any) != window.location.pathname) { - window.location.assign(window.location.pathname); - } - } - }; return (
@@ -95,54 +102,56 @@ export const Layout = ({ page, children }) => {
-
+
{children}
diff --git a/src/web/questions/components/QuestionOptions.tsx b/src/web/questions/components/QuestionOptions.tsx new file mode 100644 index 0000000..e200018 --- /dev/null +++ b/src/web/questions/components/QuestionOptions.tsx @@ -0,0 +1,147 @@ +import { QuestionFragment } from "../../search/queries.generated"; +import { formatProbability } from "../utils"; + +type Option = QuestionFragment["options"][0]; + +const textColor = (probability: number) => { + if (probability < 0.03) { + return "text-red-600"; + } else if (probability < 0.1) { + return "text-red-600 opacity-80"; + } else if (probability < 0.2) { + return "text-red-600 opacity-80"; + } else if (probability < 0.3) { + return "text-red-600 opacity-70"; + } else if (probability < 0.4) { + return "text-red-600 opacity-70"; + } else if (probability < 0.5) { + return "text-gray-500"; + } else if (probability < 0.6) { + return "text-gray-500"; + } else if (probability < 0.7) { + return "text-green-600 opacity-70"; + } else if (probability < 0.8) { + return "text-green-600 opacity-70"; + } else if (probability < 0.9) { + return "text-green-600 opacity-80"; + } else if (probability < 0.97) { + return "text-green-600 opacity-80"; + } else { + return "text-green-600"; + } +}; + +const primaryForecastColor = (probability: number) => { + if (probability < 0.03) { + return "bg-red-600"; + } else if (probability < 0.1) { + return "bg-red-600 opacity-80"; + } else if (probability < 0.2) { + return "bg-red-600 opacity-70"; + } else if (probability < 0.3) { + return "bg-red-600 opacity-60"; + } else if (probability < 0.4) { + return "bg-red-600 opacity-50"; + } else if (probability < 0.5) { + return "bg-gray-500"; + } else if (probability < 0.6) { + return "bg-gray-500"; + } else if (probability < 0.7) { + return "bg-green-600 opacity-50"; + } else if (probability < 0.8) { + return "bg-green-600 opacity-60"; + } else if (probability < 0.9) { + return "bg-green-600 opacity-70"; + } else if (probability < 0.97) { + return "bg-green-600 opacity-80"; + } else { + return "bg-green-600"; + } +}; + +const primaryEstimateAsText = (probability: number) => { + if (probability < 0.03) { + return "Exceptionally unlikely"; + } else if (probability < 0.1) { + return "Very unlikely"; + } else if (probability < 0.4) { + return "Unlikely"; + } else if (probability < 0.6) { + return "About Even"; + } else if (probability < 0.9) { + return "Likely"; + } else if (probability < 0.97) { + return "Very likely"; + } else { + return "Virtually certain"; + } +}; + +const chooseColor = (probability: number) => { + if (probability < 0.1) { + return "bg-blue-50 text-blue-500"; + } else if (probability < 0.3) { + return "bg-blue-100 text-blue-600"; + } else if (probability < 0.7) { + return "bg-blue-200 text-blue-700"; + } else { + return "bg-blue-300 text-blue-800"; + } +}; + +const OptionRow: React.FC<{ option: Option }> = ({ option }) => { + return ( +
+
+ {formatProbability(option.probability)} +
+
+ {option.name} +
+
+ ); +}; + +export const QuestionOptions: React.FC<{ options: Option[] }> = ({ + options, +}) => { + const isBinary = + options.length === 2 && + (options[0].name === "Yes" || options[0].name === "No"); + + const optionsSorted = options.sort((a, b) => b.probability - a.probability); + const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options. + + if (isBinary) { + return ( +
+ + {formatProbability(options[0].probability)} + + + {primaryEstimateAsText(options[0].probability)} + +
+ ); + } else { + return ( +
+ {optionsMax5.map((option, i) => ( + + ))} +
+ ); + } +}; diff --git a/src/web/questions/pages/QuestionPage.tsx b/src/web/questions/pages/QuestionPage.tsx new file mode 100644 index 0000000..c36ca11 --- /dev/null +++ b/src/web/questions/pages/QuestionPage.tsx @@ -0,0 +1,75 @@ +import { GetServerSideProps, NextPage } from "next"; +import ReactMarkdown from "react-markdown"; + +import { Query } from "../../common/Query"; +import { Card } from "../../display/Card"; +import { QuestionFooter } from "../../display/DisplayQuestion/QuestionFooter"; +import { Layout } from "../../display/Layout"; +import { QuestionFragment } from "../../search/queries.generated"; +import { ssrUrql } from "../../urql"; +import { QuestionOptions } from "../components/QuestionOptions"; +import { QuestionByIdDocument } from "../queries.generated"; + +interface Props { + id: string; +} + +export const getServerSideProps: GetServerSideProps = async ( + context +) => { + const [ssrCache, client] = ssrUrql(); + const id = context.query.id as string; + + const question = + (await client.query(QuestionByIdDocument, { id }).toPromise()).data + ?.result || null; + + if (!question) { + context.res.statusCode = 404; + } + + return { + props: { + urqlState: ssrCache.extractData(), + id, + }, + }; +}; + +const QuestionCardContents: React.FC<{ question: QuestionFragment }> = ({ + question, +}) => ( +
+

+ + {question.title} + +

+ + + + + {question.description} + +
+); + +const QuestionPage: NextPage = ({ id }) => { + return ( + +
+ + + {({ data }) => } + + +
+
+ ); +}; + +export default QuestionPage; diff --git a/src/web/questions/queries.generated.tsx b/src/web/questions/queries.generated.tsx new file mode 100644 index 0000000..04ee65a --- /dev/null +++ b/src/web/questions/queries.generated.tsx @@ -0,0 +1,13 @@ +import * as Types from '../../graphql/types.generated'; + +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +import { QuestionFragmentDoc } from '../search/queries.generated'; +export type QuestionByIdQueryVariables = Types.Exact<{ + id: Types.Scalars['ID']; +}>; + + +export type QuestionByIdQuery = { __typename?: 'Query', result: { __typename?: 'Question', id: string, url: string, title: string, description: string, timestamp: number, visualization?: string | null, options: Array<{ __typename?: 'ProbabilityOption', name?: string | null, probability?: number | null }>, platform: { __typename?: 'Platform', id: string, label: string }, qualityIndicators: { __typename?: 'QualityIndicators', stars: number, numForecasts?: number | null, numForecasters?: number | null, volume?: number | null, spread?: number | null, sharesVolume?: number | null, openInterest?: number | null, liquidity?: number | null, tradeVolume?: number | null } } }; + + +export const QuestionByIdDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"QuestionById"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","alias":{"kind":"Name","value":"result"},"name":{"kind":"Name","value":"question"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"Question"}}]}}]}},...QuestionFragmentDoc.definitions]} as unknown as DocumentNode; \ No newline at end of file diff --git a/src/web/questions/queries.graphql b/src/web/questions/queries.graphql new file mode 100644 index 0000000..a06beb4 --- /dev/null +++ b/src/web/questions/queries.graphql @@ -0,0 +1,5 @@ +query QuestionById($id: ID!) { + result: question(id: $id) { + ...Question + } +} diff --git a/src/web/questions/utils.ts b/src/web/questions/utils.ts new file mode 100644 index 0000000..f7f4f1c --- /dev/null +++ b/src/web/questions/utils.ts @@ -0,0 +1,10 @@ +export const formatProbability = (probability: number) => { + let percentage = probability * 100; + let percentageCapped = + percentage < 1 + ? "< 1%" + : percentage > 99 + ? "> 99%" + : percentage.toFixed(0) + "%"; + return percentageCapped; +};