Skip to content

Commit 6339243

Browse files
carolstranbenjie
andauthored
Create Frequently Asked Questions (FAQ) Page (graphql#942)
* Initial commit of FAQ page * Add answers for initial FAQ (graphql#943) * Initial commit following Gatsby migration and review from graphql#930 * Update FAQ based on feedback from Andreas * Apply suggestions from Benjie's code review Co-authored-by: Benjie Gillam <[email protected]> * Update license attribution Co-authored-by: Benjie Gillam <[email protected]> * Add prereq note to learn question * Update foundation numbers * Update JS question based on Ivan's review Co-authored-by: Benjie Gillam <[email protected]> Co-authored-by: Benjie Gillam <[email protected]>
1 parent ade2339 commit 6339243

File tree

5 files changed

+129
-1
lines changed

5 files changed

+129
-1
lines changed

src/assets/css/_css/docs.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@
162162
}
163163
}
164164

165+
.faq-questions::before {
166+
content: "\A";
167+
white-space: pre;
168+
}
169+
165170
img {
166171
max-width: 100%;
167172
}

src/components/FAQLayout/index.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from "react"
2+
import { Link } from "gatsby"
3+
import Marked from '../Marked'
4+
import { toSlug } from '../../utils/slug'
5+
6+
interface Props {
7+
title: string
8+
questions: string
9+
rawMarkdownBody: string
10+
}
11+
12+
const index = ({ title, questions, rawMarkdownBody }: Props) => {
13+
return (
14+
<section>
15+
<div className="documentationContent">
16+
<div className="inner-content">
17+
<h1>{title}</h1>
18+
{questions && (
19+
<div>
20+
{questions
21+
.split(',')
22+
.map(question => (
23+
<Link className="faq-questions" key={question} to={`#${toSlug( question )}`}>
24+
{question}
25+
</Link>
26+
))
27+
}
28+
</div>
29+
)}
30+
<Marked>{rawMarkdownBody}</Marked>
31+
</div>
32+
</div>
33+
</section>
34+
)
35+
}
36+
37+
export default index

src/components/HeaderLinks/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const links: LinkItem[] = [
1111
{ section: "learn", text: "Learn", href: "/learn/" },
1212
{ section: "code", text: "Code", href: "/code/" },
1313
{ section: "community", text: "Community", href: "/community/" },
14+
{ section: "faq", text: "FAQ", href: "/faq/" },
1415
{
1516
section: "spec",
1617
text: "Spec",

src/content/faq/General.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Frequently Asked Questions (FAQ)
3+
layout: faq
4+
category: General
5+
permalink: /faq/
6+
questions: Why should I use GraphQL?,Is GraphQL a database language like SQL?,Does GraphQL replace REST?,How can I learn GraphQL?,Is GraphQL frontend or backend?,Is GraphQL only for React or JavaScript developers?,What is a GraphQL client and why would I use one?,Is GraphQL owned by Facebook?,What is the GraphQL Foundation?,How can I contribute to the GraphQL specification?
7+
---
8+
9+
## Why should I use GraphQL?
10+
11+
It depends on your use case, but in general, GraphQL has a few key features that stand out. For example, GraphQL enables you to:
12+
13+
* Aggregate data from [multiple UI components](/learn/queries/#fragments).
14+
* Create a representation of your data that feels familiar and natural ([a graph](/learn/thinking-in-graphs/#it-s-graphs-all-the-way-down)).
15+
* Ensure that all of your data is [statically typed](/learn/schema/) and these types inform [what queries the schema supports](/learn/introspection/).
16+
* [Reduce the need for breaking changes](/learn/best-practices/#versioning), but utilize a [built-in mechanism for deprecations](https://spec.graphql.org/draft/#sec-Deprecation) when you need to.
17+
* Access to a [powerful tooling ecosystem](/code/#tools) with GUIs, editor integrations, code generation, linting, analytics, and more.
18+
19+
[Our homepage](/) outlines even more reasons to use GraphQL.
20+
21+
You can try out GraphQL without rewriting your entire application. For example, starting with a single HTTP request that wraps an existing REST call. Your [GraphQL schema](/learn/thinking-in-graphs/#shared-language) and [business domain model](/learn/thinking-in-graphs/#business-logic-layer) can expand gradually. We recommend focusing on one use case at first and only building the part of the schema needed for that.
22+
23+
## Is GraphQL a database language like SQL?
24+
25+
No, but this is a common misconception.
26+
27+
GraphQL is a specification typically used for remote client-server communications. Unlike SQL, GraphQL is agnostic to the data source(s) used to retrieve data and persist changes. Accessing and manipulating data is performed with arbitrary functions called [resolvers](/learn/execution/). GraphQL coordinates and aggregates the data from these resolver functions, then returns the result to the client. Generally, these resolver functions should delegate to a [business logic layer](/learn/thinking-in-graphs/#business-logic-layer) responsible for communicating with the various underlying data sources. These data sources could be remote APIs, databases, [local cache](/learn/caching/), and nearly anything else your programming language can access.
28+
29+
For more information on how to get GraphQL to interact with your database, check out our [documentation on resolvers](/learn/execution/#root-fields-resolvers).
30+
31+
## Does GraphQL replace REST?
32+
33+
No, not necessarily. They both handle APIs and can [serve similar purposes](/learn/thinking-in-graphs/#business-logic-layer) from a business perspective. GraphQL is often considered an alternative to REST, but it’s not a definitive replacement.
34+
35+
GraphQL and REST can actually co-exist in your stack. For example, you can abstract REST APIs behind a [GraphQL server](https://www.howtographql.com/advanced/1-server/). This can be done by masking your REST endpoint into a GraphQL endpoint using [root resolvers](/learn/execution/#root-fields-resolvers).
36+
37+
For an opinionated perspective on how GraphQL compares to REST, check out [How To GraphQL](https://www.howtographql.com/basics/1-graphql-is-the-better-rest/).
38+
39+
## How can I learn GraphQL?
40+
41+
There are many resources available to help you learn GraphQL, including this website. In [our documentation](/learn/), you’ll find a series of articles that explain essential GraphQL concepts and how they work. Our [Community page](/community) is full of resources to reference and groups to join.
42+
43+
For more practical guides, visit the [How to GraphQL](https://www.howtographql.com/) fullstack tutorial website. We also have a free online course with edX, [Exploring GraphQL: A Query Language for APIs](https://www.edx.org/course/exploring-graphql-a-query-language-for-apis).
44+
45+
Before you start your learning journey, make sure you know what an API is and how communication generally works between client and server.
46+
47+
## Is GraphQL frontend or backend?
48+
49+
Both. GraphQL specifies how you can [exchange information between client and server](https://www.howtographql.com/basics/3-big-picture/). This includes how the server can indicate [what data and operations are available](/learn/introspection/), how the client should [format requests](/learn/queries/), how the server should [execute these queries](/learn/execution/), and what the client will [receive in response](/learn/serving-over-http/#response).
50+
51+
## Is GraphQL only for React or JavaScript developers?
52+
53+
No, not at all. [GraphQL is a specification](https://spec.graphql.org/) that can be [implemented in any language](/learn/schema/#type-language). Our [Code page](/code/) contains a long list of libraries in many different programming languages to help with that.
54+
55+
It’s understandable why you’d think this, though. GraphQL was introduced at a [React conference](https://www.youtube.com/watch?v=9sc8Pyc51uU) and [GraphQL.js](/graphql-js/) is one of the most widely used implementations to date. We know this can be confusing, so we’re working to improve our documentation and add more code samples that aren’t written in JavaScript.
56+
57+
## What is a GraphQL client and why would I use one?
58+
59+
GraphQL clients can help you handle [queries, mutations,](/learn/queries/) and [subscriptions](https://spec.graphql.org/draft/#sec-Subscription) to a [GraphQL server](https://www.howtographql.com/advanced/1-server/). They use the underlying structure of a GraphQL API to automate certain processes. This includes batching, UI updates, build-time schema validation, and more.
60+
61+
A [list of GraphQL clients](/code/#graphql-clients) in various languages is available on our Code page. There’s also an [in-depth explanation of their benefits](https://www.howtographql.com/advanced/0-clients/) on How To GraphQL.
62+
63+
You don't need a specific client to work with GraphQL, though. You might want to start out by [issuing GraphQL results with a regular HTTP client](/learn/serving-over-http/). Then later switch to a GraphQL-optimized client as your application grows in complexity.
64+
65+
## Is GraphQL owned by Facebook?
66+
67+
No, GraphQL is governed by the [GraphQL Foundation](#what-is-the-graphql-foundation).
68+
69+
That said, the specification was originally developed at Facebook and [Facebook is a member](https://foundation.graphql.org/members/) of the GraphQL Foundation. You might notice that some of our [GitHub repositories](https://github.com/graphql/) still have the license listed under Facebook Inc. We're updating those and have already converted major projects, like [GraphiQL](https://github.com/graphql/graphiql/blob/main/LICENSE) and [DataLoader](https://github.com/graphql/dataloader/blob/master/LICENSE), to the the new copyright: "Copyright (c) 2020 GraphQL Contributors."
70+
71+
## What is the GraphQL Foundation?
72+
73+
The [GraphQL Foundation](https://foundation.graphql.org/faq/) is a neutral foundation that provides governance for GraphQL. This includes vendor-neutral oversight of open-source repositories, funding, events, and more. It's hosted under the [Linux Foundation](https://www.linuxfoundation.org/) and consists of [representatives from dozens of different companies](https://foundation.graphql.org/members/). The idea is that it’s an impartial and open home for the GraphQL community.
74+
75+
You can find out more by visiting [foundation.graphql.org](https://foundation.graphql.org/).
76+
77+
## How can I contribute to the GraphQL specification?
78+
79+
GraphQL is still an evolving language and contributions are very welcome! The specification (including the [latest working draft](https://spec.graphql.org/)) is open source. [Contributor guidelines](https://github.com/graphql/graphql-spec/blob/master/CONTRIBUTING.md) are available on GitHub.
80+
81+
There are more ways to get involved with GraphQL beyond the specification though. Updating the content on [this website and the documentation](https://github.com/graphql/graphql.github.io), for example. Or contributing to [graphql-js](https://github.com/graphql/graphql-js), [express-graphql](https://github.com/graphql/express-graphql), [GraphiQL](https://github.com/graphql/graphiql), or [one of the many other projects](https://github.com/graphql/) maintained by the [GraphQL Foundation](#what-is-the-graphql-foundation).

src/templates/doc.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Layout from "../components/Layout"
44
import DocsLayout from "../components/DocsLayout"
55
import BlogLayout from '../components/BlogLayout';
66
import CodeLayout from "../components/CodeLayout";
7+
import FAQLayout from "../components/FAQLayout";
78

89
interface Props {
910
data: any
@@ -14,12 +15,13 @@ const layoutMap: any = {
1415
docs: DocsLayout,
1516
blog: BlogLayout,
1617
code: CodeLayout,
18+
faq: FAQLayout,
1719
}
1820

1921
const Blog = ({ data, pageContext }: Props) => {
2022
const {
2123
doc: {
22-
frontmatter: { title, date, permalink, byline, guestBio, layout },
24+
frontmatter: { title, date, permalink, byline, guestBio, layout, questions },
2325
rawMarkdownBody,
2426
},
2527
nextDoc,
@@ -33,6 +35,7 @@ const Blog = ({ data, pageContext }: Props) => {
3335
permalink={permalink}
3436
byline={byline}
3537
guestBio={guestBio}
38+
questions={questions}
3639
rawMarkdownBody={rawMarkdownBody}
3740
nextDoc={nextDoc}
3841
sideBarData={pageContext.sideBarData}
@@ -52,6 +55,7 @@ export const query = graphql`
5255
guestBio
5356
sublinks
5457
layout
58+
questions
5559
}
5660
id
5761
rawMarkdownBody

0 commit comments

Comments
 (0)