content-graphql
Generates an executable graphql schema from a list of masks.
Usage
npm install content-graphql graphql --save
const pg = ;const graphql = ; // create a prismic repository with a mask named `Page`const masks = Page: Main: uid: type: "UID" config: label: "slug" ;const schema = ; const query = `{ searchOne{ uid }}`; ;
Api
;
Debug
Setting the environment variable CONTENT_GRAPHQL_DEBUG=true will log queries that are actually sent to prismic.
Assumptions
- slice names must be globaly unique across masks. (A global Slice interface is declared)
Structured Text
StructuredText will be transformed to HTML using PrismicDOM.RichText.asHtml
.
Link Resolving
Link resolving can be done server side by providing the optional linkResolver
option.
TODO
[] add more tests
[] handle image sizes
Changelog
1.0.6
- add DEBUG_CONTENT_GRAPHQL env variable to enable logging
1.0.5
- add CONTENT_GRAPHQL_API_CACHE env variable
1.0.4
- fix language issue with local file content
1.0.3
- fix cache issue
- fix lang query issue
1.0.2
- only cache ref for 5 seconds in production mode
1.0.1
All queries are now resolved by filtering a single json document instead af sending all queries to prismic.
- removed query argument from search and searchOne
- added
type
argument to search and searchOne. - added
uid
argument to search and searchOne
BREAKING CHANGE
# beforesearch(query: "[[:d = at(my.document.type, \"article\")]]) { title} # aftersearch(type: "article") { title} # beforesearch(query: "[[:d = at(my.article.uid, \"my-artcile\")]]) { title} # aftersearch(type: "article", uid: "article") { title}
0.0.19
- add ability to assign multiple masks to the same graphqltype see typeResolver feature
- add searchOneAsType
0.0.18
- add id
0.0.17
- fix missing url field on root values (was only working with Link fields)
0.0.16
- handle null values in link
0.0.14
- change preTransform for transformTextField
- allow link resolving serverside
- render structured text server side
0.0.13
- fix overfetching issue
- preTransform function
- add debug env
0.0.11
fix issue with linked documents
0.0.11
fix issue with linked documents
0.0.10
fix another transform bug
0.0.9
transform bug fix
0.0.8
transform
0.0.7
Language support
0.0.6
Handle masks with "-"
0.0.5
handle unknown slices
0.0.4
handle lower case mask names
0.0.1
initial version