Skip to content

Commit

Permalink
docs: new source plugin tutorial (#23363)
Browse files Browse the repository at this point in the history
* write sourcing nodes section

* add section on optimized images

* add the last advanced sections of the tutorial for schema customizing and subscriptions

* retire the pixabay tutorial, add redirects to new tutorial

* add reference to cloud guide

* chore: format

* add redirect from pixabay to new tutorial

* Update docs/tutorial/source-plugin-tutorial.md

Co-Authored-By: Kyle Gill <kylerobertgill@gmail.com>

* Apply suggestions from code review

Co-Authored-By: LB <laurie@gatsbyjs.com>
Co-Authored-By: Lennart <lekoarts@gmail.com>

* Apply suggestions from code review

Co-Authored-By: LB <laurie@gatsbyjs.com>

* Apply suggestions from code review

Co-Authored-By: LB <laurie@gatsbyjs.com>

* update code example to remove extraneous styles

* chore: format

* Apply suggestions from code review

Co-authored-by: Aisha Blake <aisha@gatsbyjs.com>

Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
Co-authored-by: LB <laurie@gatsbyjs.com>
Co-authored-by: Lennart <lekoarts@gmail.com>
Co-authored-by: Aisha Blake <aisha@gatsbyjs.com>
  • Loading branch information
5 people committed May 6, 2020
1 parent 192faf6 commit 2630758
Show file tree
Hide file tree
Showing 12 changed files with 990 additions and 401 deletions.
2 changes: 1 addition & 1 deletion docs/contributing/docs-contributions.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Sometimes it makes sense to move or rename a file as part of docs restructuring

```yaml:title=www/redirects.yaml
- fromPath: /docs/source-plugin-tutorial/
toPath: /tutorial/pixabay-source-plugin-tutorial/
toPath: /tutorial/source-plugin-tutorial/
```

## Claim your swag
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/creating-a-source-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,5 +482,5 @@ Then the new data needs to be pulled in via a live update like a websocket (in t
## Additional resources
- Working example repository on [creating source plugins](https://github.com/gatsbyjs/gatsby/tree/master/examples/creating-source-plugins) with the features in this guide implemented
- Tutorial on [Creating a Pixabay Image Source Plugin](/tutorial/pixabay-source-plugin-tutorial/)
- Tutorial on [Creating a Source Plugin](/tutorial/source-plugin-tutorial/)
- [`gatsby-node-helpers`](https://github.com/angeloashmore/gatsby-node-helpers), a community-made npm package with helper functions to generate Node objects with required fields like IDs and the `contentDigest` MD5 hash.
2 changes: 1 addition & 1 deletion docs/docs/gatsby-vendor-partnership.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Current partners have reported development timelines of 2-3 days when the conten

If you have a GraphQL-based API, you **may not need to build an integration at all** -- Gatsby supports integration with GraphQL APIs via so-called ["schema stitching"](/blog/2018-09-25-announcing-graphql-stitching-support/).

If you have questions while building your Gatsby integrations, try reading other supporting documentation such as the [general plugin authoring guide](/docs/creating-plugins/) and [source plugin tutorial](/tutorial/pixabay-source-plugin-tutorial/).
If you have questions while building your Gatsby integrations, try reading other supporting documentation such as the [general plugin authoring guide](/docs/creating-plugins/) and [source plugin tutorial](/tutorial/source-plugin-tutorial/).

If you still have questions, please [raise an issue on GitHub](https://github.com/gatsbyjs/gatsby/issues), ask a question in [Discord chat](https://gatsby.dev/discord), or reach out to our team at [developer-relations@gatsbyjs.com](mailto:developer-relations@gatsbyjs.com).

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/recipes/sourcing-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ query MyPokemonQuery {

- Walk through an example using the `gatsby-source-filesystem` plugin in [tutorial part five](/tutorial/part-five/#source-plugins)
- Search available source plugins in the [Gatsby library](/plugins/?=source)
- Understand source plugins by building one in the [Pixabay source plugin tutorial](/tutorial/pixabay-source-plugin-tutorial/)
- Understand source plugins by building one in the [source plugin tutorial](/tutorial/source-plugin-tutorial/)
- The createNode function [documentation](/docs/actions/#createNode)

## Sourcing Markdown data for blog posts and pages with GraphQL
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/schema-gql-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Now we can create a GraphQL Field declaration whose type is `AuthorYaml` (which

#### Foreign Key reference (`___NODE`)

If not a mapping field, it might instead end in `___NODE`, signifying that its value is an ID that is a foreign key reference to another node in redux. Check out the [Source Plugin Tutorial](/tutorial/pixabay-source-plugin-tutorial/) for how this works from a user point of view. Behind the scenes, the field inference is handled by [inferFromFieldName](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/infer-graphql-type.js#L204).
If not a mapping field, it might instead end in `___NODE`, signifying that its value is an ID that is a foreign key reference to another node in redux. Check out the [Source Plugin Tutorial](/tutorial/source-plugin-tutorial/) for how this works from a user point of view. Behind the scenes, the field inference is handled by [inferFromFieldName](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/infer-graphql-type.js#L204).

This is actually quite similar to the mapping case above. We remove the `___NODE` part of the field name. E.g. `author___NODE` would become `author`. Then, we find our `linkedNode`. I.e given the example value for `author` (which would be an ID), we find its actual node in redux. Then, we find its type in processed types by its `internal.type`. Note, that also like in mapping fields, we can define the `linkedField` too. This can be specified via `nodeFieldname___NODE___linkedFieldName`. E.g. for `author___NODE___name`, the linkedField would be `name` instead of `id`.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sourcing-from-private-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ There are 3 approaches that you can use to source data from your private API:

1. If your private API is a GraphQL API, you can use [`gatsby-source-graphql`](/packages/gatsby-source-graphql/).
2. If your private API is not a GraphQL API and you are new to GraphQL, treat the data as unstructured data and fetch it during build time, as described by the guide "[Using Gatsby without GraphQL](/docs/using-gatsby-without-graphql/)". However, as highlighted in the guide, this approach comes with some tradeoffs.
3. Create a source plugin, as described in the tutorial "[Source plugin tutorial](/tutorial/pixabay-source-plugin-tutorial/)".
3. Create a source plugin, as described in the tutorial "[Source plugin tutorial](/tutorial/source-plugin-tutorial/)".

## Other considerations

Expand Down
Loading

0 comments on commit 2630758

Please sign in to comment.