From 64c969a9082505abe47a23f84c246ba173282847 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 4 Mar 2020 15:37:06 +0100 Subject: [PATCH] fix: add explicit schema for hidden challenges --- client/gatsby-node.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/gatsby-node.js b/client/gatsby-node.js index bd51d687ba..9aae9a774f 100644 --- a/client/gatsby-node.js +++ b/client/gatsby-node.js @@ -210,3 +210,41 @@ exports.onCreateBabelConfig = ({ actions }) => { } }); }; + +// Typically the schema can be inferred, but not when some challenges are +// skipped (at time of writing the Chinese only has responsive web design), so +// this makes the missing fields explicit. +exports.createSchemaCustomization = ({ actions }) => { + const { createTypes } = actions; + const typeDefs = ` + type ChallengeNode implements Node { + question: Question + videoId: String + required: ExternalFile + files: ChallengeFile + } + type Question { + text: String + answers: [String] + solution: Int + } + type ChallengeFile { + indexhtml: FileContents + indexjs: FileContents + indexjsx: FileContents + } + type ExternalFile { + link: String + src: String + } + type FileContents { + key: String + ext: String + name: String + contents: String + head: String + tail: String + } + `; + createTypes(typeDefs); +};