Prisma1: Polymorphic relations

Created on 21 Dec 2016  路  3Comments  路  Source: prisma/prisma1

Hi Guys,
in a CMS you probably would like to have an array of various content types declared as a schema inside of a parent schema:

-- Page
  -- title (string)
  -- slug (string|unique)
  -- contentElements (relation|1:n)
    --> currently only one schema is possible in the dropdown..
    --> multi-selection of allowed schema types would be a great improvement

I do miss this kind of setup in the current backend. I found out that its possible with a workaround but it feels rather inconvenient, from the editor point of view and for the developer.
Cheers

Most helpful comment

Hi @dohomi The way we would support this is with GraphQL interfaces. It would allow you to write a query in the following ways:

Page(slug:"cool-post"){
    photos: contentElements(filter: {__typename: "Photo"}){
      ... on Photo {
        url
      }
    }
    messages: contentElements(filter: {__typename: "Message"}){
      ... on Message {
        text
      }
    }
  }

or

Page(slug:"cool-post"){
  contentElements{
  __typename
    ... on Photo {
      url
    }
    ... on Message {
      text
    }
  }
}

You can read more about this here http://graphql.org/learn/queries/#inline-fragments

Would this be a compelling solution to you?

All 3 comments

Hi @dohomi The way we would support this is with GraphQL interfaces. It would allow you to write a query in the following ways:

Page(slug:"cool-post"){
    photos: contentElements(filter: {__typename: "Photo"}){
      ... on Photo {
        url
      }
    }
    messages: contentElements(filter: {__typename: "Message"}){
      ... on Message {
        text
      }
    }
  }

or

Page(slug:"cool-post"){
  contentElements{
  __typename
    ... on Photo {
      url
    }
    ... on Message {
      text
    }
  }
}

You can read more about this here http://graphql.org/learn/queries/#inline-fragments

Would this be a compelling solution to you?

@sorenbs yes that would be a great fit!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  路  3Comments

schickling picture schickling  路  3Comments

ragnorc picture ragnorc  路  3Comments

sedubois picture sedubois  路  3Comments

sorenbs picture sorenbs  路  3Comments