Create schema for dictionary in app service

Hello!
I have a collection which stores python dict. I want to build a schema in app service for graphQL. My dict looks like this:

"job_list": {
    "job_1: {
        info: {
            "a":1,
           "b":2,
        }
    },
    "job_2: {
        info: {
            "p":111,
           "q":12,
        }
    },
    "job_3: {
        info: {
            "x":11,
           "y":22,
        }
    }
}

Thanks

2 Likes

This doc says that I can create dict type by not defining property field and setting additionalProperty field. But when I do that I get a warning “schema must have a “properties” field” and then I can’t access that particular attribute while querying in graphql

2 Likes

I have a simmiliar issue. I try to define dictionary in schema as it decribed in docs:

    "consumed": {
      "bsonType": "object",
      "additionalProperties": {
        "bsonType": "string"
      }
    },

but I get error: schema must have a “properties” field

Hi Edgar,

The schema format should look like this:

{
  "bsonType": "object",
  "title": "<Type Name>",
  "required": ["<Required Field Name>", ...],
  "properties": {
    "<Field Name>": <Schema>
  }
}

It sounds like you’re missing the properties field as shown, Is this present?

Regards
Manny

Hi, well just adding properties like this:

"test": {
  "bsonType": "object",
  "properties": {}
}

still gives error: schema must have a “properties” field
adding a a field in properties works:

"test": {
  "bsonType": "object",
  "properties": {
    "test1": {
      "bsonType": "string"
    }
  }
}

but this will not give a dictionary. Desired result is a collection of dynamic and unique string keys paired with values of a given type as described in docs

Hi Edgar,

Could you share your app id?

Here:

example-qjcct

I have made a new app with separate cluster to demonstrate it. Technically I decided to change my data structure in a way that I no longer need this feature, but it still could be interesting to figure it out for a future reference.