Skip to content

Question - Support for multi-level resources? #144

@atul-nagar

Description

@atul-nagar

Hello,
I'm trying to create a multi-level heirarchy of resources, but am unable to get it to work beyond two top level resources. Below is the schema definition:

var Foundation = schema.Schema{
	Description: "Schema describing foundation",
	Fields: schema.Fields{
		"id": schema.IDField,
		"name": {
			Required:   true,
			Filterable: true,
			Sortable:   true,
			Validator:  &schema.String{},
		},
	},
}
var Org = schema.Schema{
	Description: "Schema describing Org",
	Fields: schema.Fields{
		"id": schema.IDField,
		"name": {
			Required:   true,
			Filterable: true,
			Sortable:   true,
			Validator:  &schema.String{},
		},
		"foundation": {
			Required:   true,
			Filterable: true,
			Sortable:   true,
			Validator: &schema.Reference{
				Path: "foundations",
			},
		},
	},
}

var Space = schema.Schema{
	Description: "Schema describing Space",
	Fields: schema.Fields{
		"id": schema.IDField,
		"name": {
			Required:   true,
			Filterable: true,
			Sortable:   true,
			Validator:  &schema.String{},
		},
		"org": {
			Required:   true,
			Filterable: true,
			Sortable:   true,
			Validator: &schema.Reference{
				Path: "orgs",
			},
		},
	},
}

And the corresponding binding:

foundations := index.Bind("foundations", fractal_schema.Foundation, mem.NewHandler(), resource.Conf{
		AllowedModes: resource.ReadWrite,
	})

	orgs := foundations.Bind("orgs", "foundation", fractal_schema.Org, mem.NewHandler(), resource.Conf{
		AllowedModes: resource.ReadWrite,
	})

	spaces := orgs.Bind("spaces", "org", fractal_schema.Space, mem.NewHandler(), resource.Conf{
		AllowedModes: resource.ReadWrite,
	})

This gives me the following error:
{"time":"2017-09-28T14:59:34+05:30","level":"fatal","message":"Invalid API configuration: foundations.orgs.spaces: schema compilation error: org: can't find resource 'orgs'"}
exit status 1

Any tips would be helpful.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions