Comments (4)
There is a reproduction of this issue at https://github.com/1of1studio/repro-sanity-codegen - the only customisation is to add an alias for a sanity ui component to no-op in order to get sanity-codegen to run.
Note: Will require a projectId in sanity.json to run sanity of course
from sanity-shopify-studio.
Hey @joeswann – thanks for the clear report and providing a repro here!
The documentation you've linked is correct! But it's worth pointing out that those naming restrictions apply specifically to field names and not document names.
For instance, if you try and create a field with the name alternate.name
, Sanity will throw an error and the studio won't run at all. However, periods in document names are valid and these are used extensively throughout the studio (Sanity assets are documents named sanity.imageAsset
and sanity.fileAsset
)
I can't speak for sanity-codegen
– it looks like it may be applying field name validation to document names as well, but it may have a good reason for doing so!
from sanity-shopify-studio.
Hi @robinpyon and thank you for the quick response!
That's a great clarification, I have a couple of follow up thoughts to cover then:
-
First - The documentation is a bit unclear on this because Sanity specifically states that documents are a kind of object, even going so far as to say
Apart from the above, documents are defined just like regular objects, so see the documentation of the object type for more info about how to define documents.
. This is a little loose though and it may not be intended to specifically include the field name validation, that idea would be bolstered if sanity usessanity.fileAsset
already. -
Second, I think some of the objects actually do have a period in their field name, such as
seo.singleton
,seo.standard
andseo.product
- these do not appear to be documents? Could it be that they don't break Sanity due to their field name being different when actually applied (im not sure whether Sanity validates the source object name or only the destination when referencing the object type in schema?).
Codegen may only be trying to generate types for externally defined schema, which might be why it wasn't already an issue with sanity.fileAsset... Not sure on that one!
from sanity-shopify-studio.
No worries!
First - The documentation is a bit unclear on this because Sanity specifically states that documents are a kind of object ... [t]his is a little loose though and it may not be intended to specifically include the field name validation ...
I should have been clearer by instead saying "periods in object and document names are valid" instead. The docs are correct though – and the fields
property on the document page does point to the fields section in the document page.
That said, I agree with you that this is a little unclear. Given that fields
are shared across both documents and objects, perhaps there's an argument for abstracting that out into a separate page.
Second, I think some of the objects actually do have a period in their field name, such as seo.singleton, seo.standard and seo.product - these do not appear to be documents?
That's correct, these are infact objects which are referenced by other documents (or even other objects).
Im not sure whether Sanity validates the source object name or only the destination when referencing the object type in schema?).
Sanity will validate ALL object names at runtime (even if unreferenced) and will also throw errors when you try and reference an object that doesn't yet exist in your schema.
I'm going to close this as I don't believe this issue lies with this specific studio setup, but please feel free to continue the conversation here!
from sanity-shopify-studio.
Related Issues (20)
- productVariant "image" field is never synced HOT 2
- Where is the custom sync function located? HOT 3
- Show specific products in collection? HOT 6
- It doesn't work along with github.com/sanity-io/hydrogen-sanity-demo
- Metafields and Metaobjects for Shopify HOT 1
- Bug: TypeScript errors in blocksToText.js
- Can't connect from Shopify HOT 3
- Included annotations are not rendering their icons and inline styles HOT 1
- Typescript error when initializing with JS
- What shopify plan do I need to use it? HOT 1
- Template "shopify" not found HOT 3
- Can't add items (Menu) HOT 2
- Upgrade Path HOT 2
- Support for page, blog and article templates
- Looks like the example sanity studio isn't working. HOT 3
- Schema: Lift anonymous object types
- isAvailable doesn't seem to return any value? HOT 2
- Encountered anonymous inline object HOT 1
- Cannot get storeId HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanity-shopify-studio.