Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't seem to work #1

Open
i-am-the-slime opened this issue Jun 21, 2020 · 1 comment
Open

Doesn't seem to work #1

i-am-the-slime opened this issue Jun 21, 2020 · 1 comment

Comments

@i-am-the-slime
Copy link

After following the instructions I get this:

error  Cannot query field "allGuestbook" on type "Query"

This is the config:

    {
      resolve: `gatsby-source-faunadb`,
      options: {
        // The secret for the key you're using to connect to your Fauna database.
        // You can generate on of these in the "Security" tab of your Fauna Console.
        secret: "***",
        // The name of the index you want to query
        // You can create an index in the "Indexes" tab of your Fauna Console.
        index: `guestbook-entries`,
        // If your index requires arguments, you can specify them like this.
        // You can omit this property if your index doesn't need any.
        // arguments: ["bird"],
        // This is the name under which your data will appear in Gatsby GraphQL queries
        // The following will create queries called `allGuestbook` and `guestbook`.
        type: "guestbook",
        // If you need to limit the number of documents returned, you can specify a 
        // maximum number to read.
        size: 100
      },
@pollen8
Copy link

pollen8 commented Aug 28, 2020

I just stumbled across the same error. For me it was because I was trying to query an empty index.
At that point Gatsby won't be able to infer the types and wont create a node in the schema for you.

To resolve the issue I think you can add the schema into gatsby-node.js:

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions;

  // Avoid build errors if no notifications exist
  createTypes(`
    type allFaunaNotification implements Node {
        id: ID
        message: String
        nodes: String
    }
  `)

  createTypes(`
    type faunaNotification implements Node {
        id: ID
        message: String
    }
  `)
}

For this to work I had to create both types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants