algolia / gatsby-plugin-algolia

A plugin to push to Algolia based on graphQl queries
https://yarn.pm/gatsby-plugin-algolia
Apache License 2.0
177 stars 45 forks source link

Can not push data pulled from airtable into gatsby to algolia #39

Closed kayali1411 closed 4 years ago

kayali1411 commented 4 years ago

I can fetch data from airtable using gatsby graphql playground while gatsby running on development mode, but I am unable to push data pulled from airtable into gatsby to algolia when I run npm run build.

gatsby-config.js

const queries = require("./src/utils/algolia")

module.exports = {
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-styled-components`,
    {
      resolve: `gatsby-source-airtable`,
      options: {
        apiKey: `${process.env.AIRTABLE_API_KEY}`,
        tables: [
          {
            baseId: `${process.env.AIRTABLE_BASE_ID}`,
            tableName: `Products`
          },
          {
            baseId: `${process.env.AIRTABLE_BASE_ID}`,
            tableName: `Categories`
          }
        ]
      }
    },
    {
      resolve: `gatsby-plugin-algolia`,
      options: {
        appId: `${process.env.GATSBY_ALGOLIA_APP_ID}`,
        apiKey: `${process.env.ALGOLIA_ADMIN_KEY}`,
        indexName: `${process.env.ALGOLIA_INDEX_NAME}`,
        queries,
        chunkSize: 10000,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`,
      },
    },
  ],
}

algolia.js

const ProductsQuery = `{
  allAirtable(filter: {table: {eq: "Products"}}) {
    nodes {
      data {
        productId
        name
        slug
        sku
        description
        price
        categories
      }
    }
  }
}`

const flatten = arr =>
  arr.map(({ data }) => ({
    ...data
  }))

const queries = [
  {
    query: ProductsQuery,
    transformer: ({ data }) => flatten(data.allAirtable.nodes),
  }
]

module.exports = queries

Error message ERROR #11321 PLUGIN "gatsby-source-airtable" threw an error while running the sourceNodes lifecycle: Could not find what you are looking for(NOT_FOUND)[Http code 404] ⠧ source and transform nodes npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! gatsby-starter-default@0.1.0 build: gatsby build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the gatsby-starter-default@0.1.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/kayali/.npm/_logs/2019-10-09T17_46_13_630Z-debug.log

/Users/kayali/.npm/_logs/2019-10-09T17_46_13_630Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.9.0
3 info using node@v10.16.2
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle gatsby-starter-default@0.1.0~prebuild: gatsby-starter-default@0.1.0
6 info lifecycle gatsby-starter-default@0.1.0~build: gatsby-starter-default@0.1.0
7 verbose lifecycle gatsby-starter-default@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle gatsby-starter-default@0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/shopgo/Desktop/kayali/snipcart/myjam-gatsby/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/mongodb/bin:/usr/local/mongodb/bin:/usr/local/mongodb/bin
9 verbose lifecycle gatsby-starter-default@0.1.0~build: CWD: /Users/shopgo/Desktop/kayali/snipcart/myjam-gatsby
10 silly lifecycle gatsby-starter-default@0.1.0~build: Args: [ '-c', 'gatsby build' ]
11 silly lifecycle gatsby-starter-default@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle gatsby-starter-default@0.1.0~build: Failed to exec build script
13 verbose stack Error: gatsby-starter-default@0.1.0 build: `gatsby build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid gatsby-starter-default@0.1.0
15 verbose cwd /Users/shopgo/Desktop/kayali/snipcart/myjam-gatsby
16 verbose Darwin 18.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.16.2
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error gatsby-starter-default@0.1.0 build: `gatsby build`
22 error Exit status 1
23 error Failed at the gatsby-starter-default@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Haroenv commented 4 years ago

Does the exact same query work in the __graphql explorer?

kayali1411 commented 4 years ago

@Haroenv yes and use graphql directly inside gatsby pages it works too. the only issue I have in indexing the data to algolia.

Haroenv commented 4 years ago

It's been a while since i worked on this, so I opened a gatsby issue, please follow up there with your env info: https://github.com/gatsbyjs/gatsby/issues/18437

kayali1411 commented 4 years ago

@Haroenv I do not know if the issue from gatsby, since I was working with contentful and I was able to do push data from contentful to algolia using gatsby.

Haroenv commented 4 years ago

it might be with the airtable plugin, i haven't used it yet

kayali1411 commented 4 years ago

you are correct, for that reason I opened the same issue on both algolia plugin and airtable plugin https://github.com/jbolda/gatsby-source-airtable/issues/91

Haroenv commented 4 years ago

can you modify this with data anyone can use @kayali1411 https://github.com/Haroenv/gatsby-bug-report

Haroenv commented 4 years ago

please comment on the gatsby bug

bhupendra1011 commented 4 years ago

Hey @Haroenv , I am exactly getting the same error when I try push markdown content to algolia vis gatsby-plugin-alogolia. Here are more details on the same.

Hey @kayali1411 , how did u resolved the issue . I am getting same error have verified API keys and query in __graphQL playground.