Giter VIP home page Giter VIP logo

gatsby-source-bgg's Introduction

Gatsby + BoardGameGeek

gatsby-source-bgg

Source plugin for pulling game collections from BoardGameGeek into Gatsby. It creates links between entry types and assets (e.g. cover images) so they can be queried in Gatsby using GraphQL.

At a glance

Node.js CI Minzipped bundle size npm version

Getting started

First, install the package

# npm install gatsby-source-bgg
yarn add gatsby-source-bgg

Then, in your gatsby-config.js add the plugin and configure it with all the filters and options you like. The only required field is username. Here you can find a complete list of options.

The options are a 1:1 mapping of the API options you can find on BoardGameGeek's documentation.

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-bgg",
      options: {
        username: "tommasoamici",
        own: 1,
      },
    },
  ],
};

You will then be able to query the games as usual with GraphQL queries, e.g.

query GamesList {
  games: allBggGame {
    edges {
      node {
        name
        numPlays
        coverImage {
          childImageSharp {
            gatsbyImageData(height: 256, width: 256, formats: [AUTO, WEBP])
          }
        }
      }
    }
  }
}

Example output:

{
  "data": {
    "games": {
      "edges": [
        {
          "node": {
            "name": "7 Wonders Duel",
            "numPlays": 5,
            "coverImage": {
              "childImageSharp": {
                "gatsbyImageData": {
                  "layout": "constrained",
                  "backgroundColor": "#282828",
                  "images": {
                    "fallback": {
                      "src": "/static/283f546e590850a05dfea6196db90991/68974/pic3376065.jpg",
                      "srcSet": "/static/283f546e590850a05dfea6196db90991/d4a57/pic3376065.jpg 64w,\n/static/283f546e590850a05dfea6196db90991/19e71/pic3376065.jpg 128w,\n/static/283f546e590850a05dfea6196db90991/68974/pic3376065.jpg 256w,\n/static/283f546e590850a05dfea6196db90991/3c367/pic3376065.jpg 512w",
                      "sizes": "(min-width: 256px) 256px, 100vw"
                    },
                    "sources": [
                      {
                        "srcSet": "/static/283f546e590850a05dfea6196db90991/8257c/pic3376065.webp 64w,\n/static/283f546e590850a05dfea6196db90991/6766a/pic3376065.webp 128w,\n/static/283f546e590850a05dfea6196db90991/22bfc/pic3376065.webp 256w,\n/static/283f546e590850a05dfea6196db90991/d689f/pic3376065.webp 512w",
                        "type": "image/webp",
                        "sizes": "(min-width: 256px) 256px, 100vw"
                      }
                    ]
                  },
                  "width": 256,
                  "height": 256
                }
              }
            }
          }
        }
      ]
    }
  },
  "extensions": {}
}

Found a bug?

Please file a report in this repository's issues

Development

If you want to contribute to this project, that's great to hear!

You can start at CONTRIBUTING.md.

gatsby-source-bgg's People

Contributors

renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar tommasoamici avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gatsby-source-bgg's Issues

Cannot read property 'result' of undefined

What version of gatsby-source-bgg are you using?

1.0.8

What version of Node.js are you using?

14.17.1

Describe the Bug

"gatsby-source-bgg" threw an error while running the sourceNodes lifecycle:

Cannot read property 'result' of undefined

TypeError: Cannot read property 'result' of undefined

  • polls.ts:18 Object.processSuggestedAgePoll
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/src/polls.ts:18:16

  • index.ts:52
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/src/index.ts:52:27

  • Array.map

  • index.ts:13 Object.processData
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/src/index.ts:13:15

  • index.ts:125
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/src/index.ts:125:12

  • index.js:32 step
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/dist/index.js:32:23

  • index.js:13 Object.next
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/dist/index.js:13:53

  • index.js:4 fulfilled
    /Users/tamici/dev/personal/tommasoamici.com/.yarn/$$virtual/gatsby-source-bgg-virtual-715b
    bd8e9c/2/gatsby-source-bgg/dist/index.js:4:58

  • runMicrotasks

  • task_queues.js:95 processTicksAndRejections
    internal/process/task_queues.js:95:5

Expected Behavior

No response

To Reproduce

No response

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @types/node-fetch to v2.6.11
  • chore(deps): update dependency @types/node to v18.19.31
  • chore(deps): update dependency typescript to v5.4.5
  • chore(deps): update gatsby monorepo (gatsby, gatsby-plugin-image, gatsby-plugin-sharp, gatsby-source-filesystem, gatsby-transformer-sharp)
  • fix(deps): update dependency node-fetch to v2.7.0
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency vitest to v1
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build.yml
  • actions/checkout v3
.github/workflows/composite/build/action.yml
  • pnpm/action-setup v2
  • actions/setup-node v3
.github/workflows/pull-requests.yml
  • actions/checkout v3
npm
example/package.json
  • gatsby 5.12.8
  • gatsby-plugin-image 3.12.2
  • gatsby-plugin-pnpm 1.2.10
  • gatsby-plugin-sharp 5.12.2
  • gatsby-transformer-sharp 5.12.2
  • react 18.2.0
  • react-dom 18.2.0
package.json
  • fast-xml-parser ^3.19.0
  • gatsby-source-filesystem ^5.0.0
  • node-fetch ^2.6.1
  • @semantic-release/changelog 6.0.3
  • @semantic-release/commit-analyzer 9.0.2
  • @semantic-release/git 10.0.1
  • @semantic-release/github 8.1.0
  • @semantic-release/npm 9.0.2
  • @semantic-release/release-notes-generator 10.0.3
  • @types/node 18.18.6
  • @types/node-fetch 2.6.7
  • @vitest/coverage-c8 0.31.4
  • conventional-changelog-conventionalcommits 5.0.0
  • gatsby 5.12.8
  • husky 8.0.3
  • lint-staged 13.3.0
  • prettier 2.8.8
  • semantic-release 19.0.5
  • typescript 5.2.2
  • vitest 0.31.4
  • gatsby 3.x || 4.x || 5.x
  • gatsby-plugin-sharp *
  • gatsby-transformer-sharp *
  • node >=18

  • Check this box to trigger a request for Renovate to run again on this repository

Package fails to install because of husky hooks

error .../node_modules/gatsby-source-bgg: Command failed.
Exit code: 127
Command: husky install
Arguments: 
Directory: .../node_modules/gatsby-source-bgg
Output: /bin/sh: husky: command not found

Subsequent builds fail without cleaning cache between them

Missing onError handler for invocation 'building-schema', error was 'Invariant Violation: Encountered an error trying to infer a GraphQL type for:
`coverImage___NODE`. There is no corresponding node with the `id` field matching: "[list of IDs]".'. Stacktrace was 'Invariant Violation: Encountered an error trying to infer a
GraphQL type for: `coverImage___NODE`. There is no corresponding node with the `id` field matching:

poll.results.map is not a function

What version of gatsby-source-bgg are you using?

1.0.8

What version of Node.js are you using?

14.17.1

Describe the Bug

ERROR #11321 PLUGIN

"gatsby-source-bgg" threw an error while running the sourceNodes lifecycle:

poll.results.map is not a function

TypeError: poll.results.map is not a function

  • polls.ts:37 Object.processSuggestedNumPlayersPoll
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ src/polls.ts:37:24

  • index.ts:51
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ src/index.ts:51:28

  • Array.map

  • index.ts:13 Object.processData
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ src/index.ts:13:15

  • index.ts:125
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ src/index.ts:125:12

  • index.js:32 step
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ dist/index.js:32:23

  • index.js:13 Object.next
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ dist/index.js:13:53

  • index.js:4 fulfilled
    [gatsby-source-bgg-npm-1.0.8-bff9ea3960-e2e68e0651.zip]/[gatsby-source-bgg]/ dist/index.js:4:58

  • task_queues.js:95 processTicksAndRejections
    internal/process/task_queues.js:95:5

Expected Behavior

No response

To Reproduce

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.