jbolda / gatsby-source-airtable

MIT License
216 stars 43 forks source link

queryName query #178

Closed psmedia closed 4 years ago

psmedia commented 4 years ago

Thanks for this wonderful plug-in, which is super useful! But I'm cracking my head trying to get the queryName option to run, so that I can have better distinguish data from two separate tables to run createPage across two different templates. My GraphQL continues to show only Airtable and allAirtable tables, even after running "gatsby clean", despite trying many variations.

Within Airtable or allAirtable tables I can see a new field, "queryName": true, But I am expecting to see new tables AirtableTable1 and AirtableTable2 here. Or do I have the wrong end of the stick? gatsby: 2.19.45 gatsby-source-airtable: 2.1.0 gatsby-cli: 2.11.0

{
      resolve: `gatsby-source-airtable`,
      options: {
        apiKey: `key************`, // may instead specify via env, see below
        concurrency: 5, // default, see using markdown and attachments for more information
        tables: [
          {
            baseId: `app***********`,
            tableName: `Table1`,
            queryName: true, // optionally default is false - makes all records in this table a separate node type, based on your tableView, or if not present, tableName, e.g. a table called "Fruit" would become "allAirtableFruit". Useful when pulling many airtables with similar structures or fields that have different types. See https://github.com/jbolda/gatsby-source-airtable/pull/52.
          },
          {
            baseId: `app**************`,
            tableName: `Table2`,
            queryName: true,
          }
        ]
      }
    }
jbolda commented 4 years ago

👋 Thanks for the kind words.

I think you are on the right track. queryName is expecting a string with the name of your choosing. For example in Table1, you may want queryName: TableOne. (I don't know how numbers in graphql work, maybe they are fine?)

If you have suggestions to make the documentation more clear, I always appreciate pull requests 😊 .

martinliptak commented 4 years ago

I've just come across the same issue. I did this to to log the error:

Screenshot 2020-04-14 at 6 13 10 PM

And found out that the table name I was using was wrong.

AirtableError {
  error: 'NOT_FOUND',
  message: 'Could not find table Travel_Bucket_List in application appXXXXXXXXXXX',
  statusCode: 404
}
jbolda commented 4 years ago

That probably isn't intuitive that that error just gets fed through to the graphql query. I wonder if maybe we wrap this in a try/catch block and throw a console.warn so this is more obvious.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any recent activity for 30 days. It will be closed if no further activity occurs within 7 days. Remove stale label, comment, and/or apply "ongoing issue" label to prevent this from being closed. Thank you for your contributions.