Closed chapster11 closed 4 years ago
Closed this by mistake this is still an issue and getting the same error for linked documents. Anyone able to help with this ?
Hi @chapster11,
It appears your icon
custom type is not part of your schemas
plugin option. You'll need to provide the JSON schema for all of your custom types so the GraphQL system understands what is available.
Thanks @angeloashmore, my schema is showing that it is added. See schema in my first post. And it is been added to the options portion the plugin. See below the "customtypes" : [ "icon" ], Should it be something else. The schema file was copied directly from the JSON custom types in Prismic.
"careers_corporate_icon" : {
"type" : "Link",
"config" : {
"select" : "document",
"customtypes" : [ "icon" ],
"label" : "Careers Corporate Icon"
}
}
As long as the icon
JSON schema is provided to the plugin it should work.
Could you try removing the corporate_icon
alias on your query just to test if it's related? There's an open issue right now with aliases not resolving correctly so I'd like to rule that out first: https://github.com/angeloashmore/gatsby-source-prismic/issues/133
Also, could you post your compiled type paths file? There should be a file in your /public
folder named prismic-typepaths---*.json
, where "*" is a MD5 hash. This will tell us what PrismicAllDocumentTypes includes.
Thanks for your help in diagnosing this. 👍
Thanks angeloashmore is there somewhere I can send the link without posting on a public thread. I removed the aliasing and I still get the same error.
careers_corporate_icon {
document {
... on PrismicIcon {
data {
name
}
}
}
}
For the prismic-typepaths---.json please send me a private message. Thanks and thanks for looking into this issue. There isn't even a mention of PrismicAllDocumentTypes in the prismic-typepaths---.json file.
I also noticed raw is been used differently now too. Might want to add this to your docs for other folks who might come across this one. That's if this is the case.
raw {
link_type
}
Needs to be now just raw without the brackets.
@angeloashmore let me know if there is anything else you might need from me ? apart from the prismic-typepaths---.json file. which I commented on above.
Thanks
@chapster11 You could create a secret gist and DM me the link on Twitter (@angeloashmore).
Good point on the docs. We'll have to update the migration guide and any mention of the raw
field in the README.
@chapster11 Migration guide is updated: https://github.com/angeloashmore/gatsby-source-prismic/blob/633b01144b7de68d5956533430ed4f91525e6a2a/docs/migrating-from-v2-to-v3.md#using-raw-fields
@angeloashmore tried to direct message you on Twitter and it says angeloashmore can't be messaged. Thanks for updating the docs. Can you open your DM to me.
Here is what it says in the prismic-typepaths.json file for careers_corporate_icon
{
"path": [
"about_page",
"data",
"careers_corporate_icon"
],
"type": "PrismicLinkType"
},
I'm banging my head for days on this any other ideas ? as my json is directly from Primsic.
@chapster11 Sorry, I didn't realize I had public DMs turned off. Could you try again?
Ok resent it thanks!
Is there any progress on the aliased issue from #133 I'm in the same boat as others it would be a nightmare to go through hundreds of pages and remove every aliased query.
Thanks,
Got it! I don't see PrismicIcon
defined anywhere in the typepaths file. Are you sure you are providing it to the plugin options? It should look something like this:
"schemas": {
+ icon: require('./src/schemas/icon.json'),
about_page: require('./src/schemas/about_page.json'),
// the rest of your schemas
}
@angeloashmore Oh boy I think thats what it might be. I didn't know it was that literal. So basically ever type in Prismic has to be added to the schema. I thought it might be more forgiving so as to fall back to what V1 would do if a specific schema file was not added.
I'm getting more errors now but I think they are similar I need to go through a crazy amount of documents and make sure every type is included. I'll keep you posted on if that fixes all the issues, but could be a few days before I get to go through ever error.
Is this a deprecated warning from gatsby or from v3 of gatsby-source-prismic. Do see anything in the docs about it so maybe its Gatsby docs.
warn Deprecation warning - adding inferred resolver for field PrismicBrandColor.first_publication_date. In Gatsby v3, only fields with an explicit directive/extension will get a resolver.
Thanks again for the help on all this !!
No problem, happy to help! Yes, you will need to provide a schema JSON file for each custom type on Prismic. The plugin will fallback to the older V2 style of inferring the shape if a schema is not provided, but the linked documents system is quite different so it will not fallback there.
Ideally, Prismic will provide an API to automatically fetch the schemas. Until then, the schemas will need to be provided manually, unfortunately.
Out of curiosity, how many custom types do you manage in Prismic?
Disabling the inferred resolvers is planned effectively making providing schemas 100% required. This will resolve that warn
message. In addition, nice developer-friendly messages is planned to help through issues like this one.
See this PR for more details on nice error messages: https://github.com/angeloashmore/gatsby-source-prismic/pull/144#issuecomment-543395748
Great thanks for the explanation. Can't wait for Prismic to release that fetch feature, love it. I believe 60 so far but thats going to rise.
Ok good by the sounds of it this warning inferred resolver is going away and I don't need to adjust anything in my code right ?
I'm getting a different error now one that I've seen before and went away when I added the schema for it. its a very different error. Want me to open a different issue for this one ?
Correct, you can ignore the inferred resolver warning for now. I see the same warnings on projects I work on as well, so I'll see if there's an easy fix.
Sure, could you open a new issue? I'll close this one since it seems to be resolved.
Order of the schemas does not matter, btw. Saw your original message before the edit. 😉
Running into this issue with my graphql that worked in V2 but throwing this error in V3. "gatsby-source-prismic": "^3.0.0-beta.11",
Anyone know why this might be happening. I'm presuming its to do with the new way queries handle linked documents. But can't seem to figure out what I'm doing wrong ?
My Schema is