ahmdigital / content-model-graph Goto Github PK
View Code? Open in Web Editor NEWGraph your Sanity.io content model straight in your Studio using this tool
License: MIT License
Graph your Sanity.io content model straight in your Studio using this tool
License: MIT License
Hi @joshredwards , I just installed this in a work project and while it works well, there's still a lot of generic boilerplate in the documentation for usage that hasn't been updated for the plugin's usage. I had to dig into the package to find the name of the plugin, as the docs on Sanity and npm still refer to it as myPlugin({})
instead of ContentModelGraph()
. On the Sanity plugin page listing, there is still a warning that the plugin is only compatible with Sanity Studio v2, when it has been updated to v3. I'm not sure if that can be changed on your end or if someone from Sanity has to take it off the "not compatible with v3" list. Updating these details will probably boost plugin adoption significantly!
The good news is once I got it working, it made sense of a moderately complex schema for our CMS use case, which uses a pageBuilder style of fragmenting our schemas to be 1:1 with our components. ๐ It shows the entire schema from a high level, but ideally we want to use it for illustrating prospective schema changes in a PR - is this possible?
This looks like a fantastic plugin!
Sadly, it immediately crashes Sanity Studio for me:
Stack trace:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
Any hints as to how I can overcome this?
Its hard to share these right now, especially big ones. Give me a button!
Thanks for that plugin! Really easy to use ๐
There's a little catch though that I stumpled upon.
The schema is in german, sorry about that, if it makes it easier to understand I will translate it for you, but I think you will get the idea:
The "Gerichte" document is not totally isolated as it appears in the graph but is actually referenced in the "Runden" document. It is references inside an array of references. So my guess is that references in that form are not correctly displayed yet.
Here's the part of the "Runden" schema where the dishes are referenced
{
title: "Gerichte",
name: "dishes",
type: "array",
of: [
{
type: "reference",
to: [{ type: "dish" }],
},
],
},
Let me know if you need any other info or help.
Here's the dependencies
"@sanity/base": "^2.10.5",
"@sanity/components": "^2.0.5",
"@sanity/core": "^2.10.5",
"@sanity/dashboard": "^2.10.5",
"@sanity/default-layout": "^2.10.5",
"@sanity/default-login": "^2.10.5",
"@sanity/desk-tool": "^2.10.5",
"@sanity/google-maps-input": "^2.10.5",
"@sanity/vision": "^2.10.5",
Graph wont render and crashes my studio instance.
Be very helpful to have this updated and working with the newer versions of Sanity.
Thanks for the great tool!
Due to GraphQL restrictions, references cannot be inline in arrays and have to be extracted and referenced as types. The issue is that this library faild to build the correct model when the references are not inline.
This is the code for inline references and the model built (correct):
{
name: 'myObject',
type: 'object',
fields: [
{
name: 'myArrayOfReferences',
type: 'array',
of: [
{
name: 'myReferencedTypeReference',
type: 'reference',
to: {
type: 'myReferencedType',
},
},
],
},
],
}
And this is the code with the reference as an external type (which is equivalent to the previous code) and the model built (incorrect):
{
name: 'myReferencedTypeReference',
type: 'reference',
to: {
type: 'myReferencedType',
},
},
{
name: 'myObject',
type: 'object',
fields: [
{
name: 'myArrayOfReferences',
type: 'array',
of: [
{
type: 'myReferencedTypeReference',
},
],
},
],
}
Hey! A common scenario is that non-document schemas are defined in schema.js
, like this:
export default createSchema({
name: 'default',
types: schemaTypes.concat(
[
// documents:
article,
category,
// non-documents:
link,
video,
]
),
});
It would be great if those could be excluded from the graph, since they are effectively just fields, and clutter the graph ๐ If you want, I could make a PR for this ๐
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Configuration option 'packageRules[3].node' should be a json object, Configuration option 'packageRules[3].npm' should be a json object, Invalid configuration option: author, Invalid configuration option: bugs, Invalid configuration option: keywords, Invalid configuration option: license, Invalid configuration option: main, Invalid configuration option: name, Invalid configuration option: packageRules[0].@babel/preset-react, Invalid configuration option: packageRules[0].file-saver, Invalid configuration option: packageRules[0].lodash, Invalid configuration option: packageRules[0].prop-types, Invalid configuration option: packageRules[0].react, Invalid configuration option: packageRules[0].react-icons, Invalid configuration option: packageRules[0].styled-components, Invalid configuration option: packageRules[0].viz.js, Invalid configuration option: packageRules[1].@sanity/base, Invalid configuration option: packageRules[1].@sanity/components, Invalid configuration option: packageRules[2].@ahmdigital/eslint-config, Invalid configuration option: packageRules[2].babel-cli, Invalid configuration option: packageRules[2].babel-eslint, Invalid configuration option: packageRules[2].babel-preset-es2015, Invalid configuration option: packageRules[2].babel-preset-react, Invalid configuration option: renovate, Invalid configuration option: scripts, Invalid configuration option: version, The "node" object can only be configured at the top level of a config but was found inside "packageRules[3]", The "npm" object can only be configured at the top level of a config but was found inside "packageRules[3]"
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These problems occurred while renovating this repository. View logs.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
Dockerfile
node 16
.github/workflows/codeql-analysis.yml
actions/checkout v2
github/codeql-action v1
github/codeql-action v1
github/codeql-action v1
package.json
@babel/preset-react ^7.16.7
file-saver ^2.0.5
lodash ^4.17.21
prop-types ^15.8.1
react ^16.14.0
react-icons ^3.11.0
styled-components ^5.3.3
viz.js ^2.1.2
@ahmdigital/eslint-config 7.1.40
@typescript-eslint/parser 6.18.1
babel-cli 6.26.0
babel-preset-es2015 6.24.1
babel-preset-react 6.24.1
@sanity/base ^2.0.0
@sanity/components ^2.0.0
node ^16
.nvmrc
node 16
On the Sanity plugin page it's highlighted that this plugin only support v2 of the Studio. Yet the repo states v3 support.
Either way, when I install it and run the studio I get the following error:
No matching export in "node_modules/sanity-plugin-content-model-graph/node_modules/styled-components/dist/styled-components.browser.esm.js" for import "styled"
I've upgraded styled-components with no luck.
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.