birkir / gatsby-source-prismic-graphql

Gatsby source plugin for Prismic GraphQL
MIT License
137 stars 75 forks source link

Where query not working #133

Open benjpierce opened 4 years ago

benjpierce commented 4 years ago

Hi,

I'm using "gatsby-source-prismic-graphql": "3.3.0".

I'm using separate GraphQL queries to filter some blog articles stored in Prismic for a Gatsby site. As follows:

export const query = graphql`
  query PrismicBlogArticlesNews {
    prismic {
      allBlog_pages {
        edges {
          node {
            heading
          }
        }
      }
      allBlog_articles(sortBy: published_DESC, where: {article_type_fulltext: "News"}) {
        edges {
          node {
            ...prismicBlogArticleFields
          }
        }
      }  
    }
  }
`
export const query = graphql`
  query PrismicBlogArticlesOpinion {
    prismic {
      allBlog_pages {
        edges {
          node {
            heading
          }
        }
      }
      allBlog_articles(sortBy: published_DESC, where: {article_type_fulltext: "Opinion"}) {
        edges {
          node {
            ...prismicBlogArticleFields
          }
        }
      }  
    }
  }
`

However, the first query does not return any data when used in my codebase. Despite the fact there is data matching this in Prismic. The second query does return data. Do you have any idea why changing 'article_type_fulltext' only works in some cases?

Cheers.

TimFletcher commented 4 years ago

I also have issues with simple where queries with gatsby-source-prismic-graphql 3.3.1.

Working Query

{
  prismic {
    allTestimonials(where: {author: "Timothy Fletcher"}) {
      edges {
        node {
          author
          featured_on_the_homepage
        }
      }
    }
  }
}

Returns:

{
  "data": {
    "prismic": {
      "allTestimonials": {
        "edges": [
          {
            "node": {
              "author": "Timothy Fletcher",
              "featured_on_the_homepage": true
            }
          }
        ]
      }
    }
  }
}

Broken Query

{
  prismic {
    allTestimonials(where: {featured_on_the_homepage: true}) {
      edges {
        node {
          author
          featured_on_the_homepage
        }
      }
    }
  }
}

Returns:

{
  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "path": [
        "prismic",
        "allTestimonials"
      ],
      "stack": [
        "Error: Internal server error",
        "    at new CombinedError (/path/to/project/node_modules/graphql-tools/dist/stitching/errors.js:82:28)",
        "    at Object.checkResultAndHandleErrors (/path/to/project/node_modules/graphql-tools/dist/stitching/errors.js:98:15)",
        "    at CheckResultAndHandleErrors.transformResult (/path/to/project/node_modules/graphql-tools/dist/transforms/CheckResultAndHandleErrors.js:9:25)",
        "    at /path/to/project/node_modules/graphql-tools/dist/transforms/transforms.js:25:54",
        "    at Array.reduce (<anonymous>)",
        "    at applyResultTransforms (/path/to/project/node_modules/graphql-tools/dist/transforms/transforms.js:24:23)",
        "    at /path/to/project/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:105:50",
        "    at step (/path/to/project/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)",
        "    at Object.next (/path/to/project/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)",
        "    at fulfilled (/path/to/project/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)",
        "    at processTicksAndRejections (internal/process/task_queues.js:93:5)"
      ]
    }
  ],
  "data": null
}