From 991ae0b5dd381efb171687a65421160dc93caef3 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Mon, 12 Dec 2022 15:37:42 +0200 Subject: [PATCH 01/11] Website - DRFAT - Add new section Signed-off-by: Tuval Simha --- gatsby-node.js | 152 ++++++++++++------ src/content/code/slug-map.json | 10 +- .../code/tools/{ => gqt/General}/gqt.md | 0 .../General}/graphql-armor.md | 0 .../General}/graphql-code-generator.md | 0 .../tools/{ => microcks/General}/microcks.md | 0 .../{ => quicktype/General}/quicktype.md | 0 .../Subgraph}/schemathesis.md | 0 src/pages/code.tsx | 105 +++++++++++- 9 files changed, 205 insertions(+), 62 deletions(-) rename src/content/code/tools/{ => gqt/General}/gqt.md (100%) rename src/content/code/tools/{ => graphql-armor/General}/graphql-armor.md (100%) rename src/content/code/tools/{ => graphql-code-generator/General}/graphql-code-generator.md (100%) rename src/content/code/tools/{ => microcks/General}/microcks.md (100%) rename src/content/code/tools/{ => quicktype/General}/quicktype.md (100%) rename src/content/code/tools/{ => schemathesis/Subgraph}/schemathesis.md (100%) diff --git a/gatsby-node.js b/gatsby-node.js index c6894f6127..14a97c1fe2 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -6,13 +6,11 @@ const { readFile } = require("fs-extra") const { promisify } = require("util") exports.createSchemaCustomization = ({ actions, schema }) => { - const gql = String.raw; - const { createTypes } = actions; + const gql = String.raw + const { createTypes } = actions createTypes(gql` - type BlogPost implements Node - @childOf(types: ["MarkdownRemark"]) - { + type BlogPost implements Node @childOf(types: ["MarkdownRemark"]) { postId: String! title: String! tags: [String!]! @@ -21,8 +19,8 @@ exports.createSchemaCustomization = ({ actions, schema }) => { guestBio: String remark: MarkdownRemark! @link # backlink to the parent } - `); -}; + `) +} // Transform nodes, each of logic inside here can be extracted to a separated plugin later. exports.onCreateNode = async ({ @@ -32,32 +30,34 @@ exports.onCreateNode = async ({ createNodeId, createContentDigest, }) => { - const { createNode, createParentChildLink } = actions; + const { createNode, createParentChildLink } = actions // Derive content nodes from remark nodes - if (node.internal.type === 'MarkdownRemark') { - if (node.frontmatter.layout === 'blog') { - const nodeId = createNodeId(`${node.id} >>> BlogPost`); - - const permalink = node.frontmatter.permalink; - if (!permalink?.startsWith('/blog/')) { - reporter.panicOnBuild(`${permalink} is not valid permalink for blog post`); - return; + if (node.internal.type === "MarkdownRemark") { + if (node.frontmatter.layout === "blog") { + const nodeId = createNodeId(`${node.id} >>> BlogPost`) + + const permalink = node.frontmatter.permalink + if (!permalink?.startsWith("/blog/")) { + reporter.panicOnBuild( + `${permalink} is not valid permalink for blog post` + ) + return } // It contains a kind of transform logic. However, those logics can be extracted to resolvers into ahead of sourcing (createTypes) const blogPostContent = { id: nodeId, - postId: permalink.replace('/blog/', '').replace(/\/$/, ''), + postId: permalink.replace("/blog/", "").replace(/\/$/, ""), title: node.frontmatter.title, tags: node.frontmatter.tags ?? [], date: node.frontmatter.date, - authors: (node.frontmatter.byline ?? '') - .split(',') + authors: (node.frontmatter.byline ?? "") + .split(",") .map(name => name.trim()) .filter(Boolean), guestBio: node.frontmatter.guestBio ?? null, - }; + } createNode({ ...blogPostContent, @@ -65,27 +65,27 @@ exports.onCreateNode = async ({ parent: node.id, children: [], internal: { - type: 'BlogPost', + type: "BlogPost", contentDigest: createContentDigest(blogPostContent), }, - }); + }) createParentChildLink({ parent: node, child: blogPostContent, - }); + }) } } -}; +} exports.onCreatePage = async ({ page, actions }) => { // trying to refactor code to be "the Gatsby way". // from the paths on ready, ignores a bunch of existing custom logic below. - if (page.path.startsWith('/blog')) { - return; + if (page.path.startsWith("/blog")) { + return } - if (page.path.startsWith('/tags')) { - return; + if (page.path.startsWith("/tags")) { + return } const { createPage, deletePage } = actions @@ -108,7 +108,10 @@ exports.onCreatePage = async ({ page, actions }) => { } = await parse$(markdownFileContent, undefined) howto = howto.trim() const pathArr = markdownFilePath.split("/") - if (markdownFilePath.includes("language-support")) { + if ( + markdownFilePath.includes("language-support") || + markdownFilePath.includes("tools") + ) { const languageSupportDirIndex = pathArr.indexOf("language-support") const languageNameSlugIndex = languageSupportDirIndex + 1 const languageNameSlug = pathArr[languageNameSlugIndex] @@ -132,6 +135,28 @@ exports.onCreatePage = async ({ page, actions }) => { gem, sourcePath: markdownFilePath, }) + const toolSupportDirIndex = pathArr.indexOf("tools") + const toolNameSlugIndex = toolSupportDirIndex + 1 + const toolNameSlug = pathArr[toolNameSlugIndex] + const toolName = slugMap[toolNameSlug] + codeData.ToolsNew = codeData.ToolsNew || {} + codeData.ToolsNew[toolName] = codeData.ToolsNew[toolName] || {} + const categoryToolsNameSlugIndex = toolSupportDirIndex + 2 + const categoryToolsNameSlug = pathArr[categoryToolsNameSlugIndex] + const categoryToolsName = slugMap[categoryToolsNameSlug] + codeData.ToolsNew[toolName][categoryToolsName] = + codeData.ToolsNew[toolName][categoryToolsName] || [] + + codeData.ToolsNew[toolName][categoryToolsName].push({ + name, + description, + howto, + url, + github, + npm, + gem, + sourcePath: markdownFilePath, + }) } else { const codeDirIndex = pathArr.indexOf("code") const categoryNameSlugIndex = codeDirIndex + 1 @@ -152,7 +177,7 @@ exports.onCreatePage = async ({ page, actions }) => { }) ) const languageList = [] - let sortedTools = [] + const toolList = [] await Promise.all([ Promise.all( Object.keys(codeData.Languages).map(async languageName => { @@ -173,16 +198,31 @@ exports.onCreatePage = async ({ page, actions }) => { }) }) ), - sortLibs(codeData.Tools).then(({ sortedLibs }) => { - sortedTools = sortedLibs - }), - ]) + Promise.all( + Object.keys(codeData.ToolsNew).map(async toolName => { + const toolCategoryMap = codeData.ToolsNew[toolName] + let toolTotalStars = 0 + await Promise.all( + Object.keys(toolCategoryMap).map(async toolCategoryName => { + const libraries = toolCategoryMap[toolCategoryName] + const { sortedLibs, totalStars } = await sortLibs(libraries) + toolCategoryMap[toolCategoryName] = sortedLibs + toolTotalStars += totalStars || 0 + }) + ) + toolList.push({ + name: toolName, + totalStars: toolTotalStars, + categoryMap: toolCategoryMap, + }) + }) + ), + ]) context = { ...context, otherLibraries: { Services: codeData.Services, - Tools: sortedTools, "More Stuff": codeData["More Stuff"], }, languageList: languageList.sort((a, b) => { @@ -193,6 +233,14 @@ exports.onCreatePage = async ({ page, actions }) => { } return 0 }), + toolList: toolList.sort((a, b) => { + if (a.totalStars > b.totalStars) { + return -1 + } else if (a.totalStars < b.totalStars) { + return 1 + } + return 0 + }), } } createPage({ @@ -400,10 +448,8 @@ exports.createPages = async ({ graphql, actions }) => { let i = 0 while (page && i++ < 1000) { const { frontmatter } = page - const { - category: definedCategory, - next: definedNextPageUrl, - } = frontmatter + const { category: definedCategory, next: definedNextPageUrl } = + frontmatter let category = definedCategory || folder if (!currentCategory || category !== currentCategory.name) { if (currentCategory) { @@ -444,27 +490,27 @@ exports.createPages = async ({ graphql, actions }) => { // Use all the set up data to now tell Gatsby to create pages // on the site allPages - .filter(page => !page.permalink.startsWith('/blog')) + .filter(page => !page.permalink.startsWith("/blog")) .forEach(page => { - createPage({ - path: `${page.permalink}`, - component: docTemplate, - context: { - permalink: page.permalink, - nextPermalink: page.nextPermalink, - sideBarData: sideBardata[page.relativeDirectory], - sourcePath: page.sourcePath, - }, + createPage({ + path: `${page.permalink}`, + component: docTemplate, + context: { + permalink: page.permalink, + nextPermalink: page.nextPermalink, + sideBarData: sideBardata[page.relativeDirectory], + sourcePath: page.sourcePath, + }, + }) }) - }) } exports.onCreateWebpackConfig = ({ actions }) => { actions.setWebpackConfig({ resolve: { fallback: { - "assert": require.resolve("assert/"), - } - } + assert: require.resolve("assert/"), + }, + }, }) } diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index a4895135eb..520f8623ad 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -26,5 +26,13 @@ "client": "Client", "server": "Server", "tools": "Tools", - "services": "Services" + "services": "Services", + "gqt": "GQT", + "graphql-armor": "Graphql-Armor", + "graphql-code-generator": "GraphQL Code Generator", + "microcks": "Microcks", + "quicktype": "QuickType", + "schemathesis": "Schemathesis", + "Subgraph": "Subgraph", + "General": "General" } diff --git a/src/content/code/tools/gqt.md b/src/content/code/tools/gqt/General/gqt.md similarity index 100% rename from src/content/code/tools/gqt.md rename to src/content/code/tools/gqt/General/gqt.md diff --git a/src/content/code/tools/graphql-armor.md b/src/content/code/tools/graphql-armor/General/graphql-armor.md similarity index 100% rename from src/content/code/tools/graphql-armor.md rename to src/content/code/tools/graphql-armor/General/graphql-armor.md diff --git a/src/content/code/tools/graphql-code-generator.md b/src/content/code/tools/graphql-code-generator/General/graphql-code-generator.md similarity index 100% rename from src/content/code/tools/graphql-code-generator.md rename to src/content/code/tools/graphql-code-generator/General/graphql-code-generator.md diff --git a/src/content/code/tools/microcks.md b/src/content/code/tools/microcks/General/microcks.md similarity index 100% rename from src/content/code/tools/microcks.md rename to src/content/code/tools/microcks/General/microcks.md diff --git a/src/content/code/tools/quicktype.md b/src/content/code/tools/quicktype/General/quicktype.md similarity index 100% rename from src/content/code/tools/quicktype.md rename to src/content/code/tools/quicktype/General/quicktype.md diff --git a/src/content/code/tools/schemathesis.md b/src/content/code/tools/schemathesis/Subgraph/schemathesis.md similarity index 100% rename from src/content/code/tools/schemathesis.md rename to src/content/code/tools/schemathesis/Subgraph/schemathesis.md diff --git a/src/pages/code.tsx b/src/pages/code.tsx index f64b9487b0..d0636bb169 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -31,11 +31,20 @@ interface Language { } } +interface Tool { + name: string + totalStars: number + categoryMap: { + Subgraph: ILibrary[] + General: ILibrary[] + } +} interface PageContext { languageList: Language[] + toolList: Tool[] otherLibraries: { Services: ILibrary[] - Tools: ILibrary[] + Tools?: ILibrary[] } sourcePath: string } @@ -147,6 +156,13 @@ export function Library({ data }: { data: ILibrary }) { ) } +const categorySlugMap = [ + ["Server", toSlug("Server")], + ["Client", toSlug("Client")], + ["Tools", toSlug("Tools")], + ["Subgraph", toSlug("Subgraph")], + ["General", toSlug("General")], +] export function LibraryList({ data }: { data: ILibrary[] }) { return (
@@ -157,11 +173,84 @@ export function LibraryList({ data }: { data: ILibrary[] }) { ) } -const categorySlugMap = [ - ["Server", toSlug("Server")], - ["Client", toSlug("Client")], - ["Tools", toSlug("Tools")], -] +interface ToolsListProps { + pageContext: PageContext + type: "General" | "Subgraph" +} + +export function ToolsList({ pageContext, type }: ToolsListProps) { + const isGeneral = pageContext.toolList.find(tool => tool.categoryMap.General) + const isSubgraph = pageContext.toolList.find( + tool => tool.categoryMap.Subgraph + ) + switch (type) { + case "General": + if (isGeneral && type === "General") { + return ( + <> +

{type}

+
+ {pageContext.toolList.map(tool => { + const libraryCategories = tool.categoryMap + const filteredCategorySlugMap = categorySlugMap.filter( + ([libraryCategoryName]) => + libraryCategories[libraryCategoryName as "General"] + ) + return ( +
+ {filteredCategorySlugMap.map( + ([categoryName]) => + categoryName in libraryCategories && ( + + ) + )} +
+ ) + })} +
+ + ) + } + case "Subgraph": + if (isSubgraph && type === "Subgraph") { + return ( + <> +

{type}

+
+ {pageContext.toolList.map(tool => { + const libraryCategories = tool.categoryMap + const filteredCategorySlugMap = categorySlugMap.filter( + ([libraryCategoryName]) => + libraryCategories[libraryCategoryName as "Subgraph"] + ) + return ( +
+ {filteredCategorySlugMap.map( + ([categoryName]) => + categoryName in libraryCategories && ( + + ) + )} +
+ ) + })} +
+ + ) + } + default: + return null + } +} export default ({ pageContext }: PageProps<{}, PageContext>) => { return ( @@ -196,7 +285,6 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => {
-

Language Support

@@ -285,7 +373,8 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => { # - + +

Services From 2ad092924dc702525f88848bdd0474a5d0fdbdab Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 13 Dec 2022 14:03:10 +0200 Subject: [PATCH 02/11] console log + promise Signed-off-by: Tuval Simha --- gatsby-node.js | 81 ++++++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 14a97c1fe2..883ea403c7 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -179,46 +179,44 @@ exports.onCreatePage = async ({ page, actions }) => { const languageList = [] const toolList = [] await Promise.all([ - Promise.all( - Object.keys(codeData.Languages).map(async languageName => { - const libraryCategoryMap = codeData.Languages[languageName] - let languageTotalStars = 0 - await Promise.all( - Object.keys(libraryCategoryMap).map(async libraryCategoryName => { - const libraries = libraryCategoryMap[libraryCategoryName] - const { sortedLibs, totalStars } = await sortLibs(libraries) - libraryCategoryMap[libraryCategoryName] = sortedLibs - languageTotalStars += totalStars || 0 - }) - ) - languageList.push({ - name: languageName, - totalStars: languageTotalStars, - categoryMap: libraryCategoryMap, + ...Object.keys(codeData.Languages).map(async languageName => { + const libraryCategoryMap = codeData.Languages[languageName] + let languageTotalStars = 0 + await Promise.all( + Object.keys(libraryCategoryMap).map(async libraryCategoryName => { + const libraries = libraryCategoryMap[libraryCategoryName] + const { sortedLibs, totalStars } = await sortLibs(libraries) + libraryCategoryMap[libraryCategoryName] = sortedLibs + languageTotalStars += totalStars || 0 }) + ) + languageList.push({ + name: languageName, + totalStars: languageTotalStars, + categoryMap: libraryCategoryMap, }) - ), - - Promise.all( - Object.keys(codeData.ToolsNew).map(async toolName => { - const toolCategoryMap = codeData.ToolsNew[toolName] - let toolTotalStars = 0 - await Promise.all( - Object.keys(toolCategoryMap).map(async toolCategoryName => { - const libraries = toolCategoryMap[toolCategoryName] - const { sortedLibs, totalStars } = await sortLibs(libraries) - toolCategoryMap[toolCategoryName] = sortedLibs - toolTotalStars += totalStars || 0 - }) - ) - toolList.push({ - name: toolName, - totalStars: toolTotalStars, - categoryMap: toolCategoryMap, + }), + + ...Object.keys(codeData.ToolsNew).map(async toolName => { + const toolCategoryMap = codeData.ToolsNew[toolName] + let toolTotalStars = 0 + await Promise.all( + Object.keys(toolCategoryMap).map(async toolCategoryName => { + const libraries = toolCategoryMap[toolCategoryName] + const { sortedLibs, totalStars } = await sortLibs(libraries) + toolCategoryMap[toolCategoryName] = sortedLibs + toolTotalStars += totalStars || 0 }) + ) + toolList.push({ + name: toolName, + totalStars: toolTotalStars, + categoryMap: toolCategoryMap, }) - ), + }), ]) + + console.log("codeData.Languages", codeData.Languages.undefined.undefined) context = { ...context, otherLibraries: { @@ -242,6 +240,19 @@ exports.onCreatePage = async ({ page, actions }) => { return 0 }), } + console.log("toolList", context.toolList) + console.log( + "categoryMap", + context.toolList.map(tool => tool.categoryMap) + ) + console.log( + "categoryMap.General", + context.toolList.map(tool => tool.categoryMap.General) + ) + console.log( + "categoryMap.Subgraph", + context.toolList.map(tool => tool.categoryMap.Subgraph) + ) } createPage({ ...page, From 50313b51cb009878469b8af6132d16328cda3b1a Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 13 Dec 2022 13:21:08 +0100 Subject: [PATCH 03/11] convert to ts --- gatsby-config.js => gatsby-config.ts | 44 ++++++++++++++++------------ gatsby-node.js | 18 +++++++----- 2 files changed, 35 insertions(+), 27 deletions(-) rename gatsby-config.js => gatsby-config.ts (78%) diff --git a/gatsby-config.js b/gatsby-config.ts similarity index 78% rename from gatsby-config.js rename to gatsby-config.ts index 1e52a8232f..973a60abd4 100644 --- a/gatsby-config.js +++ b/gatsby-config.ts @@ -1,4 +1,6 @@ -module.exports = { +import type { GatsbyConfig } from "gatsby" + +const config: GatsbyConfig = { siteMetadata: { title: "GraphQL", description: @@ -87,24 +89,26 @@ module.exports = { author: byline, }) ), - query: `{ - allMarkdownRemark( - filter: {frontmatter: {layout: {eq: "blog"}}} - sort: {frontmatter: {date: DESC}} - ) { - edges { - node { - excerpt - frontmatter { - title - date - permalink - byline - } - } - } - } -}`, + query: /* GraphQL */ ` + { + allMarkdownRemark( + filter: { frontmatter: { layout: { eq: "blog" } } } + sort: { frontmatter: { date: DESC } } + ) { + edges { + node { + excerpt + frontmatter { + title + date + permalink + byline + } + } + } + } + } + `, output: "/blog/rss.xml", title: "Blog | GraphQL", feed_url: "http://graphql.org/blog/rss.xml", @@ -115,3 +119,5 @@ module.exports = { }, ], } + +export default config diff --git a/gatsby-node.js b/gatsby-node.js index 883ea403c7..dc255ba222 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -226,7 +226,8 @@ exports.onCreatePage = async ({ page, actions }) => { languageList: languageList.sort((a, b) => { if (a.totalStars > b.totalStars) { return -1 - } else if (a.totalStars < b.totalStars) { + } + if (a.totalStars < b.totalStars) { return 1 } return 0 @@ -234,7 +235,8 @@ exports.onCreatePage = async ({ page, actions }) => { toolList: toolList.sort((a, b) => { if (a.totalStars > b.totalStars) { return -1 - } else if (a.totalStars < b.totalStars) { + } + if (a.totalStars < b.totalStars) { return 1 } return 0 @@ -423,7 +425,8 @@ exports.createPages = async ({ graphql, actions }) => { const bDate = new Date(b.frontmatter.date || Date.now()) if (aDate > bDate) { return -1 - } else if (aDate < bDate) { + } + if (aDate < bDate) { return 1 } return 0 @@ -444,7 +447,6 @@ exports.createPages = async ({ graphql, actions }) => { const permalink = page.frontmatter.permalink if (!previousPagesMap[permalink] && !firstPage) { firstPage = page - return } }) @@ -500,9 +502,8 @@ exports.createPages = async ({ graphql, actions }) => { // Use all the set up data to now tell Gatsby to create pages // on the site - allPages - .filter(page => !page.permalink.startsWith("/blog")) - .forEach(page => { + for (const page of allPages) { + if (!page.permalink.startsWith("/blog")) { createPage({ path: `${page.permalink}`, component: docTemplate, @@ -513,7 +514,8 @@ exports.createPages = async ({ graphql, actions }) => { sourcePath: page.sourcePath, }, }) - }) + } + } } exports.onCreateWebpackConfig = ({ actions }) => { From 1278c0c5bab259a5968f9cea39f1e5bf64135d17 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 13 Dec 2022 13:31:37 +0100 Subject: [PATCH 04/11] refactor --- gatsby-node.js | 53 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index dc255ba222..6f154eac3b 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -5,7 +5,9 @@ const frontmatterParser = require("parser-front-matter") const { readFile } = require("fs-extra") const { promisify } = require("util") -exports.createSchemaCustomization = ({ actions, schema }) => { +const parse$ = promisify(frontmatterParser.parse) + +exports.createSchemaCustomization = ({ actions }) => { const gql = String.raw const { createTypes } = actions @@ -98,7 +100,6 @@ exports.onCreatePage = async ({ page, actions }) => { const markdownFilePaths = await globby("src/content/code/**/*.md") const codeData = {} const slugMap = require("./src/content/code/slug-map.json") - const parse$ = promisify(frontmatterParser.parse) await Promise.all( markdownFilePaths.map(async markdownFilePath => { const markdownFileContent = await readFile(markdownFilePath, "utf-8") @@ -116,15 +117,13 @@ exports.onCreatePage = async ({ page, actions }) => { const languageNameSlugIndex = languageSupportDirIndex + 1 const languageNameSlug = pathArr[languageNameSlugIndex] const languageName = slugMap[languageNameSlug] - codeData.Languages = codeData.Languages || {} - codeData.Languages[languageName] = - codeData.Languages[languageName] || {} + codeData.Languages ||= {} + codeData.Languages[languageName] ||= {} const categoryNameSlugIndex = languageSupportDirIndex + 2 const categoryNameSlug = pathArr[categoryNameSlugIndex] const categoryName = slugMap[categoryNameSlug] - codeData.Languages[languageName][categoryName] = - codeData.Languages[languageName][categoryName] || [] + codeData.Languages[languageName][categoryName] ||= [] codeData.Languages[languageName][categoryName].push({ name, description, @@ -139,13 +138,12 @@ exports.onCreatePage = async ({ page, actions }) => { const toolNameSlugIndex = toolSupportDirIndex + 1 const toolNameSlug = pathArr[toolNameSlugIndex] const toolName = slugMap[toolNameSlug] - codeData.ToolsNew = codeData.ToolsNew || {} - codeData.ToolsNew[toolName] = codeData.ToolsNew[toolName] || {} + codeData.ToolsNew ||= {} + codeData.ToolsNew[toolName] ||= {} const categoryToolsNameSlugIndex = toolSupportDirIndex + 2 const categoryToolsNameSlug = pathArr[categoryToolsNameSlugIndex] const categoryToolsName = slugMap[categoryToolsNameSlug] - codeData.ToolsNew[toolName][categoryToolsName] = - codeData.ToolsNew[toolName][categoryToolsName] || [] + codeData.ToolsNew[toolName][categoryToolsName] ||= [] codeData.ToolsNew[toolName][categoryToolsName].push({ name, @@ -162,7 +160,7 @@ exports.onCreatePage = async ({ page, actions }) => { const categoryNameSlugIndex = codeDirIndex + 1 const categoryNameSlug = pathArr[categoryNameSlugIndex] const categoryName = slugMap[categoryNameSlug] - codeData[categoryName] = codeData[categoryName] || [] + codeData[categoryName] ||= [] codeData[categoryName].push({ name, description, @@ -216,7 +214,8 @@ exports.onCreatePage = async ({ page, actions }) => { }), ]) - console.log("codeData.Languages", codeData.Languages.undefined.undefined) + console.log("codeData.Languages", codeData.Languages) + console.log("codeData.Languages.undefined.undefined", codeData.Languages.undefined.undefined) context = { ...context, otherLibraries: { @@ -243,18 +242,18 @@ exports.onCreatePage = async ({ page, actions }) => { }), } console.log("toolList", context.toolList) - console.log( - "categoryMap", - context.toolList.map(tool => tool.categoryMap) - ) - console.log( - "categoryMap.General", - context.toolList.map(tool => tool.categoryMap.General) - ) - console.log( - "categoryMap.Subgraph", - context.toolList.map(tool => tool.categoryMap.Subgraph) - ) + // console.log( + // "categoryMap", + // context.toolList.map(tool => tool.categoryMap) + // ) + // console.log( + // "categoryMap.General", + // context.toolList.filter(tool => tool.categoryMap.General) + // ) + // console.log( + // "categoryMap.Subgraph", + // context.toolList.filter(tool => tool.categoryMap.Subgraph) + // ) } createPage({ ...page, @@ -308,7 +307,7 @@ exports.createPages = async ({ graphql, actions }) => { } const tags = result.data.allBlogPost.group.map(group => group.fieldValue) - tags.forEach(tag => { + for (const tag of tags) { createPage({ path: `/tags/${tag.toLowerCase()}/`, component: path.resolve("./src/templates/{BlogPost.tags}.tsx"), @@ -316,7 +315,7 @@ exports.createPages = async ({ graphql, actions }) => { tag, }, }) - }) + } const markdownPages = result.data.allMarkdownRemark.edges From e26ce77d718ae3ed58a3493366c28edf4ea5c441 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 13 Dec 2022 13:53:08 +0100 Subject: [PATCH 05/11] fix undefined.undefined --- gatsby-node.js | 91 +++++++++---------- scripts/sort-libraries.js | 3 +- src/content/code/slug-map.json | 4 +- .../tools/gqt/{General => general}/gqt.md | 0 .../{General => general}/graphql-armor.md | 0 .../graphql-code-generator.md | 0 .../microcks/{General => general}/microcks.md | 0 .../{General => general}/quicktype.md | 0 .../{Subgraph => subgraph}/schemathesis.md | 0 9 files changed, 48 insertions(+), 50 deletions(-) rename src/content/code/tools/gqt/{General => general}/gqt.md (100%) rename src/content/code/tools/graphql-armor/{General => general}/graphql-armor.md (100%) rename src/content/code/tools/graphql-code-generator/{General => general}/graphql-code-generator.md (100%) rename src/content/code/tools/microcks/{General => general}/microcks.md (100%) rename src/content/code/tools/quicktype/{General => general}/quicktype.md (100%) rename src/content/code/tools/schemathesis/{Subgraph => subgraph}/schemathesis.md (100%) diff --git a/gatsby-node.js b/gatsby-node.js index 6f154eac3b..56547d3938 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,9 +1,9 @@ -const path = require("path") +const path = require("node:path") const sortLibs = require("./scripts/sort-libraries") const globby = require("globby") const frontmatterParser = require("parser-front-matter") -const { readFile } = require("fs-extra") -const { promisify } = require("util") +const { readFile } = require("node:fs/promises") +const { promisify } = require("node:util") const parse$ = promisify(frontmatterParser.parse) @@ -35,48 +35,47 @@ exports.onCreateNode = async ({ const { createNode, createParentChildLink } = actions // Derive content nodes from remark nodes - if (node.internal.type === "MarkdownRemark") { - if (node.frontmatter.layout === "blog") { - const nodeId = createNodeId(`${node.id} >>> BlogPost`) - - const permalink = node.frontmatter.permalink - if (!permalink?.startsWith("/blog/")) { - reporter.panicOnBuild( - `${permalink} is not valid permalink for blog post` - ) - return - } + if ( + node.internal.type === "MarkdownRemark" && + node.frontmatter.layout === "blog" + ) { + const nodeId = createNodeId(`${node.id} >>> BlogPost`) + + const { permalink } = node.frontmatter + if (!permalink?.startsWith("/blog/")) { + reporter.panicOnBuild(`${permalink} is not valid permalink for blog post`) + return + } - // It contains a kind of transform logic. However, those logics can be extracted to resolvers into ahead of sourcing (createTypes) - const blogPostContent = { - id: nodeId, - postId: permalink.replace("/blog/", "").replace(/\/$/, ""), - title: node.frontmatter.title, - tags: node.frontmatter.tags ?? [], - date: node.frontmatter.date, - authors: (node.frontmatter.byline ?? "") - .split(",") - .map(name => name.trim()) - .filter(Boolean), - guestBio: node.frontmatter.guestBio ?? null, - } + // It contains a kind of transform logic. However, those logics can be extracted to resolvers into ahead of sourcing (createTypes) + const blogPostContent = { + id: nodeId, + postId: permalink.replace("/blog/", "").replace(/\/$/, ""), + title: node.frontmatter.title, + tags: node.frontmatter.tags ?? [], + date: node.frontmatter.date, + authors: (node.frontmatter.byline ?? "") + .split(",") + .map(name => name.trim()) + .filter(Boolean), + guestBio: node.frontmatter.guestBio ?? null, + } - createNode({ - ...blogPostContent, - remark: node.id, - parent: node.id, - children: [], - internal: { - type: "BlogPost", - contentDigest: createContentDigest(blogPostContent), - }, - }) + createNode({ + ...blogPostContent, + remark: node.id, + parent: node.id, + children: [], + internal: { + type: "BlogPost", + contentDigest: createContentDigest(blogPostContent), + }, + }) - createParentChildLink({ - parent: node, - child: blogPostContent, - }) - } + createParentChildLink({ + parent: node, + child: blogPostContent, + }) } } @@ -106,12 +105,11 @@ exports.onCreatePage = async ({ page, actions }) => { let { data: { name, description, url, github, npm, gem }, content: howto, - } = await parse$(markdownFileContent, undefined) + } = await parse$(markdownFileContent) howto = howto.trim() const pathArr = markdownFilePath.split("/") if ( - markdownFilePath.includes("language-support") || - markdownFilePath.includes("tools") + markdownFilePath.includes("language-support") ) { const languageSupportDirIndex = pathArr.indexOf("language-support") const languageNameSlugIndex = languageSupportDirIndex + 1 @@ -134,6 +132,7 @@ exports.onCreatePage = async ({ page, actions }) => { gem, sourcePath: markdownFilePath, }) + } else if (markdownFilePath.includes("tools")) { const toolSupportDirIndex = pathArr.indexOf("tools") const toolNameSlugIndex = toolSupportDirIndex + 1 const toolNameSlug = pathArr[toolNameSlugIndex] @@ -194,7 +193,6 @@ exports.onCreatePage = async ({ page, actions }) => { categoryMap: libraryCategoryMap, }) }), - ...Object.keys(codeData.ToolsNew).map(async toolName => { const toolCategoryMap = codeData.ToolsNew[toolName] let toolTotalStars = 0 @@ -215,7 +213,6 @@ exports.onCreatePage = async ({ page, actions }) => { ]) console.log("codeData.Languages", codeData.Languages) - console.log("codeData.Languages.undefined.undefined", codeData.Languages.undefined.undefined) context = { ...context, otherLibraries: { diff --git a/scripts/sort-libraries.js b/scripts/sort-libraries.js index ed71188605..92388609d3 100644 --- a/scripts/sort-libraries.js +++ b/scripts/sort-libraries.js @@ -207,7 +207,8 @@ const sortLibs = async libs => { } if (bScore > aScore) { return 1 - } else if (bScore < aScore) { + } + if (bScore < aScore) { return -1 } return 0 diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index 520f8623ad..4f72a3eb93 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -33,6 +33,6 @@ "microcks": "Microcks", "quicktype": "QuickType", "schemathesis": "Schemathesis", - "Subgraph": "Subgraph", - "General": "General" + "subgraph": "Subgraph", + "general": "General" } diff --git a/src/content/code/tools/gqt/General/gqt.md b/src/content/code/tools/gqt/general/gqt.md similarity index 100% rename from src/content/code/tools/gqt/General/gqt.md rename to src/content/code/tools/gqt/general/gqt.md diff --git a/src/content/code/tools/graphql-armor/General/graphql-armor.md b/src/content/code/tools/graphql-armor/general/graphql-armor.md similarity index 100% rename from src/content/code/tools/graphql-armor/General/graphql-armor.md rename to src/content/code/tools/graphql-armor/general/graphql-armor.md diff --git a/src/content/code/tools/graphql-code-generator/General/graphql-code-generator.md b/src/content/code/tools/graphql-code-generator/general/graphql-code-generator.md similarity index 100% rename from src/content/code/tools/graphql-code-generator/General/graphql-code-generator.md rename to src/content/code/tools/graphql-code-generator/general/graphql-code-generator.md diff --git a/src/content/code/tools/microcks/General/microcks.md b/src/content/code/tools/microcks/general/microcks.md similarity index 100% rename from src/content/code/tools/microcks/General/microcks.md rename to src/content/code/tools/microcks/general/microcks.md diff --git a/src/content/code/tools/quicktype/General/quicktype.md b/src/content/code/tools/quicktype/general/quicktype.md similarity index 100% rename from src/content/code/tools/quicktype/General/quicktype.md rename to src/content/code/tools/quicktype/general/quicktype.md diff --git a/src/content/code/tools/schemathesis/Subgraph/schemathesis.md b/src/content/code/tools/schemathesis/subgraph/schemathesis.md similarity index 100% rename from src/content/code/tools/schemathesis/Subgraph/schemathesis.md rename to src/content/code/tools/schemathesis/subgraph/schemathesis.md From 3df1674bac842f23c31294221621339904b32b88 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 13 Dec 2022 14:27:54 +0100 Subject: [PATCH 06/11] fix front --- gatsby-node.js | 33 +++------------- src/pages/code.tsx | 96 +++++++++++----------------------------------- 2 files changed, 29 insertions(+), 100 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 56547d3938..f33380225d 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -108,9 +108,7 @@ exports.onCreatePage = async ({ page, actions }) => { } = await parse$(markdownFileContent) howto = howto.trim() const pathArr = markdownFilePath.split("/") - if ( - markdownFilePath.includes("language-support") - ) { + if (markdownFilePath.includes("language-support")) { const languageSupportDirIndex = pathArr.indexOf("language-support") const languageNameSlugIndex = languageSupportDirIndex + 1 const languageNameSlug = pathArr[languageNameSlugIndex] @@ -212,7 +210,6 @@ exports.onCreatePage = async ({ page, actions }) => { }), ]) - console.log("codeData.Languages", codeData.Languages) context = { ...context, otherLibraries: { @@ -238,19 +235,6 @@ exports.onCreatePage = async ({ page, actions }) => { return 0 }), } - console.log("toolList", context.toolList) - // console.log( - // "categoryMap", - // context.toolList.map(tool => tool.categoryMap) - // ) - // console.log( - // "categoryMap.General", - // context.toolList.filter(tool => tool.categoryMap.General) - // ) - // console.log( - // "categoryMap.Subgraph", - // context.toolList.filter(tool => tool.categoryMap.Subgraph) - // ) } createPage({ ...page, @@ -390,16 +374,11 @@ exports.createPages = async ({ graphql, actions }) => { return } - if (!pagesGroupedByFolder[relativeDirectory]) { - pagesGroupedByFolder = { - ...pagesGroupedByFolder, - [relativeDirectory]: [node], - } - } else { - pagesGroupedByFolder = { - ...pagesGroupedByFolder, - [relativeDirectory]: [...pagesGroupedByFolder[relativeDirectory], node], - } + pagesGroupedByFolder = { + ...pagesGroupedByFolder, + [relativeDirectory]: pagesGroupedByFolder[relativeDirectory] + ? [...pagesGroupedByFolder[relativeDirectory], node] + : [node], } allPages.push({ diff --git a/src/pages/code.tsx b/src/pages/code.tsx index d0636bb169..ef4d397f23 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -39,6 +39,7 @@ interface Tool { General: ILibrary[] } } + interface PageContext { languageList: Language[] toolList: Tool[] @@ -163,11 +164,12 @@ const categorySlugMap = [ ["Subgraph", toSlug("Subgraph")], ["General", toSlug("General")], ] + export function LibraryList({ data }: { data: ILibrary[] }) { return (
{data.map(library => ( - + ))}
) @@ -179,77 +181,25 @@ interface ToolsListProps { } export function ToolsList({ pageContext, type }: ToolsListProps) { - const isGeneral = pageContext.toolList.find(tool => tool.categoryMap.General) - const isSubgraph = pageContext.toolList.find( - tool => tool.categoryMap.Subgraph + return ( + <> +

{type}

+
+ {pageContext.toolList.map(tool => ( +
+ {Object.entries(tool.categoryMap).map( + ([categoryName, data]) => + categoryName === type && + )} +
+ ))} +
+ ) - switch (type) { - case "General": - if (isGeneral && type === "General") { - return ( - <> -

{type}

-
- {pageContext.toolList.map(tool => { - const libraryCategories = tool.categoryMap - const filteredCategorySlugMap = categorySlugMap.filter( - ([libraryCategoryName]) => - libraryCategories[libraryCategoryName as "General"] - ) - return ( -
- {filteredCategorySlugMap.map( - ([categoryName]) => - categoryName in libraryCategories && ( - - ) - )} -
- ) - })} -
- - ) - } - case "Subgraph": - if (isSubgraph && type === "Subgraph") { - return ( - <> -

{type}

-
- {pageContext.toolList.map(tool => { - const libraryCategories = tool.categoryMap - const filteredCategorySlugMap = categorySlugMap.filter( - ([libraryCategoryName]) => - libraryCategories[libraryCategoryName as "Subgraph"] - ) - return ( -
- {filteredCategorySlugMap.map( - ([categoryName]) => - categoryName in libraryCategories && ( - - ) - )} -
- ) - })} -
- - ) - } - default: - return null - } } export default ({ pageContext }: PageProps<{}, PageContext>) => { @@ -373,8 +323,8 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => { #

- - + +

Services From c48fa046bcd0ed1625107e199974394c0483b6a3 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 13 Dec 2022 15:48:42 +0200 Subject: [PATCH 07/11] change slug name Signed-off-by: Tuval Simha --- src/content/code/slug-map.json | 2 +- .../{subgraph => supergraphs}/schemathesis.md | 0 src/pages/code.tsx | 8 ++++---- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/content/code/tools/schemathesis/{subgraph => supergraphs}/schemathesis.md (100%) diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index 4f72a3eb93..e1684490a5 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -33,6 +33,6 @@ "microcks": "Microcks", "quicktype": "QuickType", "schemathesis": "Schemathesis", - "subgraph": "Subgraph", + "supergraphs": "Supergraphs", "general": "General" } diff --git a/src/content/code/tools/schemathesis/subgraph/schemathesis.md b/src/content/code/tools/schemathesis/supergraphs/schemathesis.md similarity index 100% rename from src/content/code/tools/schemathesis/subgraph/schemathesis.md rename to src/content/code/tools/schemathesis/supergraphs/schemathesis.md diff --git a/src/pages/code.tsx b/src/pages/code.tsx index ef4d397f23..d7813e6f46 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -161,7 +161,7 @@ const categorySlugMap = [ ["Server", toSlug("Server")], ["Client", toSlug("Client")], ["Tools", toSlug("Tools")], - ["Subgraph", toSlug("Subgraph")], + ["Supergraphs", toSlug("Supergraphs")], ["General", toSlug("General")], ] @@ -177,13 +177,13 @@ export function LibraryList({ data }: { data: ILibrary[] }) { interface ToolsListProps { pageContext: PageContext - type: "General" | "Subgraph" + type: "General" | "Supergraphs" } export function ToolsList({ pageContext, type }: ToolsListProps) { return ( <> -

{type}

+

{type}

{pageContext.toolList.map(tool => (
) => {

- +

Services From b9fab59e935e557a879ffc10743e02ea4192ddc0 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 13 Dec 2022 17:10:20 +0200 Subject: [PATCH 08/11] Add WunderGraph Signed-off-by: Tuval Simha --- gatsby-node.js | 4 +- src/content/code/slug-map.json | 3 +- .../{supergraphs => general}/schemathesis.md | 0 .../wundergraph/supergraphs/wundergraph.md | 87 +++++++++++++++++++ src/pages/code.tsx | 2 +- 5 files changed, 92 insertions(+), 4 deletions(-) rename src/content/code/tools/schemathesis/{supergraphs => general}/schemathesis.md (100%) create mode 100644 src/content/code/tools/wundergraph/supergraphs/wundergraph.md diff --git a/gatsby-node.js b/gatsby-node.js index f33380225d..d0f301f8e3 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -196,8 +196,8 @@ exports.onCreatePage = async ({ page, actions }) => { let toolTotalStars = 0 await Promise.all( Object.keys(toolCategoryMap).map(async toolCategoryName => { - const libraries = toolCategoryMap[toolCategoryName] - const { sortedLibs, totalStars } = await sortLibs(libraries) + const tools = toolCategoryMap[toolCategoryName] + const { sortedLibs, totalStars } = await sortLibs(tools) toolCategoryMap[toolCategoryName] = sortedLibs toolTotalStars += totalStars || 0 }) diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index e1684490a5..ade3967333 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -34,5 +34,6 @@ "quicktype": "QuickType", "schemathesis": "Schemathesis", "supergraphs": "Supergraphs", - "general": "General" + "general": "General", + "wundergraph": "WunderGraph" } diff --git a/src/content/code/tools/schemathesis/supergraphs/schemathesis.md b/src/content/code/tools/schemathesis/general/schemathesis.md similarity index 100% rename from src/content/code/tools/schemathesis/supergraphs/schemathesis.md rename to src/content/code/tools/schemathesis/general/schemathesis.md diff --git a/src/content/code/tools/wundergraph/supergraphs/wundergraph.md b/src/content/code/tools/wundergraph/supergraphs/wundergraph.md new file mode 100644 index 0000000000..4ed57a1e4b --- /dev/null +++ b/src/content/code/tools/wundergraph/supergraphs/wundergraph.md @@ -0,0 +1,87 @@ +--- +name: WunderGraph +description: WunderGraph is an open-source GraphQL Gateway that is able to compose Apollo Federation, GraphQL, REST APIs, Databases, Kafka and more. +url: https://wundergraph.com +github: wundergraph/wundergraph +--- + +[WunderGraph](https://wundergraph.com) composes all your APIs into a single unified GraphQL API and +allows you to expose your Graph as a [secure and type-safe JSON-RPC API](https://docs.wundergraph.com/docs/features/graphql-to-json-rpc-compiler). + +To get started with WunderGraph, you can use `create-wundergraph-app` to bootstrap a new project: + +```bash +npx create-wundergraph-app my-project -E nextjs-swr +``` + +On the client side, WunderGraph's JSON-RPC API integrates very well with frameworks like [Next.js, SWR](https://github.com/wundergraph/wundergraph/tree/main/examples/nextjs-swr) and React Query, +while one the backend, we're able to leverage the power of "Server-Side-Only GraphQL". +Handle authentication, authorization, validation, joins and more right in the Query Layer. + +```graphql +mutation ( + $name: String! @fromClaim(name: NAME) + $email: String! @fromClaim(name: EMAIL) + $message: String! @jsonSchema(pattern: "^[a-zA-Z 0-9]+$") +) { + createOnepost( + data: { + message: $message + user: { + connectOrCreate: { + where: { email: $email } + create: { email: $email, name: $name } + } + } + } + ) { + id + message + user { + id + name + } + } +} +``` + +The Query above requires the user to be authenticated, +injects the user's name and email from the JWT token and validates the message against a JSON Schema. + +Here's another example showcasing how we can use Server-Side GraphQL with WunderGraph's unique [join capabilities](https://docs.wundergraph.com/docs/features/cross-api-joins-to-compose-apis), +composing data from two different APIs into a single GraphQL response. + +```graphql +query ( + $continent: String! + # the @internal directive removes the $capital variable from the public API + # this means, the user can't set it manually + # this variable is our JOIN key + $capital: String! @internal +) { + countries_countries(filter: { continent: { eq: $continent } }) { + code + name + # using the @export directive, we can export the value of the field `capital` into the JOIN key ($capital) + capital @export(as: "capital") + # the _join field returns the type Query! + # it exists on every object type so you can everywhere in your Query documents + _join { + # once we're inside the _join field, we can use the $capital variable to join the weather API + weather_getCityByName(name: $capital) { + weather { + temperature { + max + } + summary { + title + description + } + } + } + } + } +} +``` + +The full [example can be found on GitHub](https://github.com/wundergraph/wundergraph/tree/main/examples/cross-api-joins). diff --git a/src/pages/code.tsx b/src/pages/code.tsx index d7813e6f46..76c64bb17e 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -35,7 +35,7 @@ interface Tool { name: string totalStars: number categoryMap: { - Subgraph: ILibrary[] + Supergraphs: ILibrary[] General: ILibrary[] } } From b9e8c6e1fb000dae5924780d0facc8a5daa36bb2 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 20 Dec 2022 20:59:52 +0200 Subject: [PATCH 09/11] Fix code review: change sub-s name + anchor link Signed-off-by: Tuval Simha --- src/assets/css/_css/code.less | 3 + src/content/code/slug-map.json | 2 +- .../wundergraph.md | 0 src/pages/code.tsx | 71 ++++++++++++------- 4 files changed, 50 insertions(+), 26 deletions(-) rename src/content/code/tools/wundergraph/{supergraphs => gateways-supergraphs}/wundergraph.md (100%) diff --git a/src/assets/css/_css/code.less b/src/assets/css/_css/code.less index 7cd96810e9..be691a9158 100644 --- a/src/assets/css/_css/code.less +++ b/src/assets/css/_css/code.less @@ -94,6 +94,9 @@ } } } + .tools-title { + margin: 0; + } .inner-content { max-width: 100%; } diff --git a/src/content/code/slug-map.json b/src/content/code/slug-map.json index ade3967333..41a51ab8d6 100644 --- a/src/content/code/slug-map.json +++ b/src/content/code/slug-map.json @@ -33,7 +33,7 @@ "microcks": "Microcks", "quicktype": "QuickType", "schemathesis": "Schemathesis", - "supergraphs": "Supergraphs", + "gateways-supergraphs": "GatewaysAndSupergraphs", "general": "General", "wundergraph": "WunderGraph" } diff --git a/src/content/code/tools/wundergraph/supergraphs/wundergraph.md b/src/content/code/tools/wundergraph/gateways-supergraphs/wundergraph.md similarity index 100% rename from src/content/code/tools/wundergraph/supergraphs/wundergraph.md rename to src/content/code/tools/wundergraph/gateways-supergraphs/wundergraph.md diff --git a/src/pages/code.tsx b/src/pages/code.tsx index 76c64bb17e..1533ac9262 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -161,7 +161,7 @@ const categorySlugMap = [ ["Server", toSlug("Server")], ["Client", toSlug("Client")], ["Tools", toSlug("Tools")], - ["Supergraphs", toSlug("Supergraphs")], + ["Gateways-supergraphs", toSlug("Gateways-supergraphs")], ["General", toSlug("General")], ] @@ -177,27 +177,28 @@ export function LibraryList({ data }: { data: ILibrary[] }) { interface ToolsListProps { pageContext: PageContext - type: "General" | "Supergraphs" + type: "General" | "GatewaysAndSupergraphs" } export function ToolsList({ pageContext, type }: ToolsListProps) { return ( <> -

{type}

-
- {pageContext.toolList.map(tool => ( -
- {Object.entries(tool.categoryMap).map( - ([categoryName, data]) => - categoryName === type && - )} -
- ))} -
+

+ {type === "GatewaysAndSupergraphs" ? "Gateways / Supergraphs" : type} +

+ {pageContext.toolList.map( + tool => ( + console.log(tool.categoryMap, tool.name), + ( +
+ {Object.entries(tool.categoryMap).map( + ([categoryName, data]) => + categoryName === type && + )} +
+ ) + ) + )} ) } @@ -316,15 +317,35 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => { ) })} -

- - Tools - - # - -

+
+
+

+ Tools +

+

+ + + Gateways/Supergraphs + + {" / "} + + General + + +

+
+
- +

Services From 027432d4643dbaa4d10219c4cdeb50de38260c69 Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 20 Dec 2022 21:09:53 +0200 Subject: [PATCH 10/11] change type Signed-off-by: Tuval Simha --- src/pages/code.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/code.tsx b/src/pages/code.tsx index 1533ac9262..b135866a90 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -35,7 +35,7 @@ interface Tool { name: string totalStars: number categoryMap: { - Supergraphs: ILibrary[] + GatewaysSupergraphs: ILibrary[] General: ILibrary[] } } From 2dbc52c9986e2d7fd71d36c1067a04cbab7f908a Mon Sep 17 00:00:00 2001 From: Tuval Simha Date: Tue, 20 Dec 2022 21:33:11 +0200 Subject: [PATCH 11/11] fix code review Signed-off-by: Tuval Simha --- src/pages/code.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/code.tsx b/src/pages/code.tsx index b135866a90..2af271ab02 100644 --- a/src/pages/code.tsx +++ b/src/pages/code.tsx @@ -317,11 +317,9 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => { ) })} -
+
-

- Tools -

+

Tools

) => {

- +

Services