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

Graphql when running gridsome develop #11

Open
gianpaj opened this issue Mar 31, 2020 · 8 comments
Open

Graphql when running gridsome develop #11

gianpaj opened this issue Mar 31, 2020 · 8 comments

Comments

@gianpaj
Copy link

gianpaj commented Mar 31, 2020

$ yarn start
 ERROR  Failed to compile with 1 errors                                                   06:46:55

 error  in ./src/pages/Index.vue?vue&type=custom&index=0&blockType=page-query

Module build failed (from ./node_modules/gridsome/lib/plugins/vue-components/lib/loaders/page-query.js):
Error: Cannot query field "name" on type "FireTopics".

GraphQL request:119:9
118 |         id
119 |         name
    |         ^
120 |         image (width: 300, height: 200)
gridsome info

  System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Binaries:
    Node: 13.11.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.13.7 - /usr/local/bin/npm
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 74.0
    Safari: 13.0.5
  npmPackages:
    gridsome: ^0.7.12 => 0.7.13
    gridsome-plugin-tailwindcss: ^2.2.30 => 2.2.43
    gridsome-source-firestore: ^1.1.12 => 1.1.12

I didn't change the gridsome.config.js file and I created the collections on Firestore:

Screenshot 2020-03-31 at 06 52 41

@u12206050
Copy link
Owner

u12206050 commented Mar 31, 2020 via email

@gianpaj
Copy link
Author

gianpaj commented Mar 31, 2020

yes. in that case works. I have remove all the other fields in all the templates as in the Index.vue file

As soon as I add the name field into the query for allFireTopics in the Index.vue, I get that error:

An error occurred while executing query for src/pages/Index.vue

Error: Cannot query field "name" on type "FireTopics".

GraphQL request:6:9
5 |         id
6 |         name
  |         ^
7 |       }

Same error in the GraphQL Playground http://localhost:8080/___explore:

{
  "error": {
    "errors": [
      {
        "message": "Cannot query field \"name\" on type \"FireTopics\".",
        "stringified": "Cannot query field \"name\" on type \"FireTopics\".\n\nGraphQL request:6:9\n5 |         id\n6 |         name\n  |         ^\n7 |       }"
      }
    ]
  }
}

for

query Topics {
  allFireTopics {
    edges {
      node {
        id
        name
        # image (width: 300, height: 200)
        # path
        # posts: belongsTo {
        #   count: totalCount
        # }
      }
    }
  }
}

Docs:
Screenshot 2020-03-31 at 16 00 22

@u12206050
Copy link
Owner

What about the other fields, if you ignore name and try image, does that field work?

@gianpaj
Copy link
Author

gianpaj commented Apr 1, 2020

okay.. i don't what the hell happened. but not the world is spinning the right way and it works 😂

cheers. for the troubleshooting & nice OSS library :)

@gianpaj gianpaj closed this as completed Apr 1, 2020
@gianpaj gianpaj reopened this Apr 1, 2020
@gianpaj
Copy link
Author

gianpaj commented Apr 1, 2020

Actually it looks like it's related to the data on Firestore.

Could you please provide an example of what fields (and its type) should each Document have for?

  • authors
  • posts
  • tags
  • topics

@u12206050
Copy link
Owner

Authors
fname: string
image: string

Posts
author: reference
title: string
excerpt: string
body: string
image: string
tags: array
topic: reference

Tags
name: string

Topics
name: string
info: string
image: string

@u12206050
Copy link
Owner

Have you been able to solve this? Can you close it if you did?

@justinleapline
Copy link

Found the issue from above. The code doesn't handle an empty post collection. So if there are no posts found, it errors on pulling the records. Additionally, you need to have the status (String) field in the posts collection set to '1' to return the posts within the collection, as filtered within the gridsome.config.js.

Grateful for the work @u12206050 - experimenting with incorporating gridsome and firebase on a new project. Appreciate the work on providing a template!

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

3 participants