Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relations: Show as ID Array for JSON Schema #375

Open
rawkode opened this issue Mar 1, 2022 · 0 comments
Open

Relations: Show as ID Array for JSON Schema #375

rawkode opened this issue Mar 1, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@rawkode
Copy link

rawkode commented Mar 1, 2022

This might be a slightly niche request, but please allow me to explain.

I store my data in Git, as YAML files. I'm modelling it as Prisma and syncing the YAML to PostgreSQL to make it available via REST and GraphQL.

The Many to One and Many to Many Models for JSON Schema assume that the sub-types are embedded, when actually for this use-case we want an array of IDs.

Example: I'm modelling my YouTube channel which has a concept of an "Episode" which features one or more technologies.

model Episode {
  id String @id

  technologies Technology[]
}

model Technology {
  id       String    @id
  episodes Episode[]
}

Which generates this embedded JSON schema on each side:

    "Episode": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "technologies": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Technology"
          }
        }
      }
    },
    "Technology": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "episodes": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Episode"
          }
        }
      }
    },

Would it be possible to get something merged that allows me to annotate these types as disjunctions so that the following was generated?

    "Episode": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "technologies": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Technology": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "episodes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
@valentinpalkovic valentinpalkovic added the enhancement New feature or request label Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants