gusnips / gatsby-source-craftcms Goto Github PK
View Code? Open in Web Editor NEWGatsby source plugin for building websites using the CraftCMS as a data source
Gatsby source plugin for building websites using the CraftCMS as a data source
Thank you for getting this working!
Is it possible to support entriesConnection style queries for relationships?
If I add one into the config, then nothing appears in the Gatsby schema, it looks like it could be because an entriesConnection query returns the data nested as data -> query -> edges
instead.
I am trying to understand what this option does? Is there some explanation of what this is?
I was hoping that I could run queries directly on the craftql endpoint through gatsby-node.js
as they will be dynamic in nature.
I'm following along with the setup instructions.
I've installed Craft, and the CraftQL plugin successfully.
In gatsby-config.js
I've added my endpoint and my token, and verified that the endpoint works by running a curl
with '{"query":"{ helloWorld }"}
. All good so far.
I've added in some content (including categories) into Craft and have been able to fetch them successfully using CraftQL's GraphiQL test tool (in the Craft CMS).
However when I run gatsby develop
it fails with
error Plugin gatsby-source-craftcms returned an error
Error: Cannot query field "categories" on type "Query".: {"response":{"errors":[{"message":"Cannot query field \"categories\" on type \"Query\".","c ategory":"graphql","locations":[{"line":2,"column":11}]}],"status":200},"request":{"query":"{\n categories(site:\"default\",groupId:12) {\n id\n title\n slug\n uri\n }\n }"}}
I'm not sure what I'm doing wrong here. Is it a GraphQL syntax issue? I'm still quite new to GraphQL so could be missing something obvious. Any help would be great!
Hi
I am able to query entries and output the data to my templates, however Global fields are not available. Here is my code:
// gatsby-config.js
plugins: [
{
resolve: `gatsby-source-craftcms`,
options: {
endpoint: `http://cms.local/api`,
token: `REDACTED`,
query: `{
globals: globals {
contact {
address
}
},
home: entries(section:[home]) {
id
title
... on Home {
subHeading
intro
ctaButton {
... on CtaButtonButton {
__typename
text
linkUrl
}
}
}
},
// etc
And then in my template:
export const query = graphql`
query {
home {
title
subHeading
intro
ctaButton {
text
linkUrl
}
}
globals {
contact {
address
}
}
}
`
In my console I get:
error Cannot query field "global" on type "Query"
If I remove the global
from the query I can successfully build and output data.home.title
.
I've tried using the CraftQL browser in the CMS and I can successfully query globals:
However, if i use GraphiQL browser IDE in Gatsby, I get this error: "message": "Cannot query field \"globals\" on type \"Query\".",
I'm confident I'm missing something but I can't find anything in the docs or in CraftQL.
Any idea what I'm doing wrong here??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.