olavea / Lillian-and-Ola-Vea-com

Lillian-and-Ola-Vea-com
1 stars 0 forks source link

[feat:] add support for Gatsby Image and ImageCDN #23

Open olavea opened 2 years ago

olavea commented 2 years ago

feat: add support for Gatsby Image and ImageCDN

IMAGE CDN

Gatsby-source-youtube-oembed Plugin Upgrade

Your dev-task: the WHAT, the WHY and the How.

«Nothing piraty about WHAT and WHY.» You say? Maybe not, but look at HOW....

How: not coding, but guessing

Guess her type

GraphQL node type
GraphQL kraken type
GraphQL octopus type
GraphQL object type

g1

Puzzle the shards of code in the right order

        interfaces: [`Node`, `RemoteFile`],
        name: `....`,
        fields: {
          youTubeId: "String!",
        },
      schema
                  .buildObjectType({

g2

Guess the name of our new type of friend

TobbieThumbnailKraken
TobbieCrowdcastThumbnailObject
ThumbnailTobbieOctopus
CrowdcastThumbnailTobbie

g3

Guess the "actions...." to "create" Tobbie

actions.createKraken(
actions.createNode(
actions.createNodeField(
actions.createTypes(

g4

your next sub-task:

I. Inside and Inside?

Inside which const do you put Tobbie's roof?

const createYouTubeNode = async (gatsbyUtils, pluginOptions, youTubeId) => {
const scrapeCrowdcast = async () => {
const createCrowdcastThumbnailNode = (gatsbyUtils) => {
const createCrowdcastTypes = (gatsbyUtils) => {

Deconstruct what two tools for Tobbie's toolshed?

const { schema, createNodeId } = gatsbyUtils;
const { actions, schema } = gatsbyUtils;
const { actions, createTypes } = gatsbyUtils;
const { createNode, createTypes } = actions;

Inside which "exports...." do we call Tobbie?

exports.createSchema = (gatsbyUtils) => {
exports.createSchemaCustomization = (gatsbyUtils) => {
exports.schemaCustomization = (gatsbyUtils) => {
exports.createCustomSchema = (gatsbyUtils) => {

M. Is your last sub-task:

Must I addRemoteFile........Interface( to Tobbie?

addRemoteFilePlayfillInterface(
addRemoteFilePolyfillInterface(
addRemoteFilePollyfilInterface(
addRemoteFilePiratyInterface(

Must we require "gatsby-plugin- …."

const {
  addRemoteFilePolyfillInterface,
} = require("gatsby-plugin-tools/polyfill-remote-file");
const {
  addRemoteFilePolyfillInterface,
} = require("gatsby-utils/polyfill-remote-file");
const {
  addRemoteFilePolyfillInterface,
} = require("gatsby-plugin-timeship/polyfill-remote-file");

You DID it! 1/3 of the treasure hunt 💪 😺 🏴‍☠️

You've done these 3 sub-tasks:

const ....Node = {    height: 630 , width: 1200, }
const .... = async (gatsbyUtils, pluginOptions, youTubeId) => {
exports.createSc....Customization = (gatsbyUtils) => {
actions.create....(

G. is for GrapiQL where we find 🍓 for fields

{
    height: 630,
...
}
exports.onCreateDevS....r = ({ app }) => {};

poly....ImageServiceDevRoutes(app);

You DID it! 2/3 of the treasure hunt 💪 😺 🏴‍☠️

C. is for createNodeId(

  const youTubeThumbnailNodeId = createNodeId(
    `${YOUTUBE_THUMBNAIL_TYPE} >>> ${....}`
  );

D. is for Dating

How can we tell the Crowdcast node to go on a blind date with the CrowdcastThumbnail node?

const createYouTubeTypes = (gatsbyUtils) => {
  const { actions, schema } = gatsbyUtils;

  actions.createTypes([
    `
    type YouTube implements Node {
      thumbnail: YouTubeThumbnail @link(
        from: "...."
        by: "...."
      )
    }
  `,

You DID it! The whole treasure hunt 💪 😺 🏴‍☠️

Ola Vea is a Gatsby-plugin-Dev who also helps Gatsby-Devs waste less time on unsticky dev-learning. Dev at POW! — the private menstrual cycle journal (usepow.app) 👑 @raae You can reach him at: ola@lillylabs

source docs/creating-a-source-plugin/#enabling-image-cdn-support