0
Dinamik olarak json yapılandırmasından bir grafik şeması oluşturmaya çalışıyorum. Ama kendi başına bir GraphQLList oluşturamıyorum.Grafik oluştururken GraphQLObjectType başvuru yapılamıyor
json:
{
"label": "user",
"properties": [
{
"key": "name",
"type": "string"
},
{
"key": "id",
"type": "id"
},
{
"key": "birthday",
"type": "date"
},
{
"key": "gender",
"type": "string"
},
{
key: 'friends',
type: 'string'
}
]
}
JavaScript kodu üreten:
graphSchemes.forEach(function (graphScheme) {
graphQLObjects[graphScheme.label] = new graphql.GraphQLObjectType({
name: graphScheme.label,
fields: graphScheme.properties.reduce((fields, property) => {
if (property.key === 'friends') {
fields[property.key] = {
type: new graphql.GraphQLList(graphQLObjects[graphScheme.label])
};
return fields;
}
fields[property.key] = {
type: TYPES[property.type]
};
return fields;
}, {})
});
});
mesele buradadır:
type: new graphql.GraphQLList(graphQLObjects[graphScheme.label])
hayır "graphQLObjects [graphScheme.label]"
Nasıl bu dolaşabiliriz yoktur? Baska öneri?