|
| 1 | +import { Button } from "@/app/conf/_design-system/button" |
| 2 | +import { SectionLabel } from "@/app/conf/_design-system/section-label" |
| 3 | +import { ReactNode } from "react" |
| 4 | + |
| 5 | +export function GraphQLAdvantages() { |
| 6 | + return ( |
| 7 | + <section className="bg-neu-50"> |
| 8 | + <div className="gql-container gql-section"> |
| 9 | + <SectionLabel>GraphQL advantages</SectionLabel> |
| 10 | + <div className="mt-8 flex flex-col gap-y-10"> |
| 11 | + <Subsection |
| 12 | + name="Precision" |
| 13 | + bigText="Ask for what you need, get exactly that" |
| 14 | + text="Send a GraphQL query to your API and get precisely the data you request — no over-fetching, no under-fetching. Predictable responses keep apps efficient and performant." |
| 15 | + figure={null} |
| 16 | + cta={ |
| 17 | + <Button href="/learn" variant="secondary"> |
| 18 | + Learn GraphQL |
| 19 | + </Button> |
| 20 | + } |
| 21 | + /> |
| 22 | + <Subsection |
| 23 | + name="Optimization" |
| 24 | + bigText="Retrieve multiple resources in one request" |
| 25 | + text="GraphQL seamlessly follows relationships between data, eliminating multiple API calls. While typical REST APIs require loading from multiple URLs, GraphQL APIs get all the data your app needs in a single request. Ideal for complex queries and optimizing network performance." |
| 26 | + figure={null} |
| 27 | + cta={ |
| 28 | + <Button href="/learn" variant="secondary"> |
| 29 | + Read the docs |
| 30 | + </Button> |
| 31 | + } |
| 32 | + /> |
| 33 | + <Subsection |
| 34 | + name="Productivity" |
| 35 | + bigText="Move faster with powerful, community-built tools" |
| 36 | + text="Know exactly what you can request without leaving editor. Highlight potential issues before sending a query and take advantage of improved code intelligence. GraphQL makes it easy to build powerful tools. And many of them, like GraphiQL, are open source and built by the GraphQL community." |
| 37 | + figure={null} |
| 38 | + cta={ |
| 39 | + <Button href="/community/tools-and-libraries" variant="secondary"> |
| 40 | + Explore GraphQL tools |
| 41 | + </Button> |
| 42 | + } |
| 43 | + /> |
| 44 | + <Subsection |
| 45 | + name="Consistency" |
| 46 | + bigText="Build confidently with a type-safe schema" |
| 47 | + text="GraphQL APIs are structured around types and fields, not rigid endpoints. This ensures data consistency, self-documentation, and clear, actionable errors. Apps can use types to avoid writing manual parsing code." |
| 48 | + figure={null} |
| 49 | + cta={ |
| 50 | + <Button href="/learn/schema" variant="secondary"> |
| 51 | + Learn more about GraphQL schemas |
| 52 | + </Button> |
| 53 | + } |
| 54 | + /> |
| 55 | + <Subsection |
| 56 | + name="Versionless" |
| 57 | + bigText="Evolve without versions" |
| 58 | + text="Add new fields and types without impacting existing queries. Deprecate outdated fields while keeping APIs clean and future-proof. By using a single evolving version, GraphQL APIs give apps continuous access to new features and encourage more maintainable server code." |
| 59 | + figure={null} |
| 60 | + cta={ |
| 61 | + <Button |
| 62 | + href="/learn/schema-design/#versioning" |
| 63 | + variant="secondary" |
| 64 | + > |
| 65 | + See more in docs |
| 66 | + </Button> |
| 67 | + } |
| 68 | + /> |
| 69 | + <Subsection |
| 70 | + name="Integration" |
| 71 | + bigText="Bring your own data and code" |
| 72 | + text="GraphQL is storage-agnostic — integrate databases, REST APIs, and third-party services into a single, cohesive data layer. Write GraphQL APIs that leverage your existing data and code with GraphQL engines available in many languages." |
| 73 | + figure={null} |
| 74 | + cta={ |
| 75 | + <Button href="/learn" variant="secondary"> |
| 76 | + Learn more about this |
| 77 | + </Button> |
| 78 | + } |
| 79 | + /> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + </section> |
| 83 | + ) |
| 84 | +} |
| 85 | + |
| 86 | +function Subsection({ |
| 87 | + name, |
| 88 | + bigText, |
| 89 | + cta, |
| 90 | + figure, |
| 91 | + text, |
| 92 | +}: { |
| 93 | + name: string |
| 94 | + bigText: ReactNode |
| 95 | + cta: ReactNode |
| 96 | + figure: ReactNode |
| 97 | + text: ReactNode |
| 98 | +}) { |
| 99 | + return ( |
| 100 | + <article className="grid lg:grid-cols-2 lg:*:[grid-column:1]"> |
| 101 | + <h3 className="typography-body-sm w-min items-center justify-center bg-sec-light px-1 py-[1.5px] font-normal dark:bg-sec-darker"> |
| 102 | + {name} |
| 103 | + </h3> |
| 104 | + <strong className="typography-h3 mt-4 font-normal lg:mt-8"> |
| 105 | + {bigText} |
| 106 | + </strong> |
| 107 | + <div className="max-lg:mt-6 lg:![grid-column:2]">{figure}</div> |
| 108 | + <p className="typography-body-lg my-6 lg:mb-4 lg:mt-8">{text}</p> |
| 109 | + {cta} |
| 110 | + </article> |
| 111 | + ) |
| 112 | +} |
0 commit comments