content-model-graph
content-model-graph copied to clipboard
Incorrect model when using references as types
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',
},
],
},
],
}

I've at least got some tests running against this repo now, so we can now modify the get nodes function and the fixtures to solve your test case.