Working with embedded types (multiple usage in another embedded type)

prisma

#1

Working with embedded types (multiple usage in another embedded type)

Hi,

I am trying to use an embedded type multiples times in another embedded type.

For the initial datamodels:

type User {
  id: ID!
  primaryProfile: PrimaryProfile
  secondaryProfile: SecondaryProfile
}
type PrimaryProfile @embedded {
  avatar: File
  images: [File!]
  video: File
  document: Document
}
type SecondaryProfile @embedded {
  notes: String
}
type Document @embedded {
  type: String!
  front: File
  back: File
}
type File @embedded {
  type: String!
  path: String!
}

I receive the following errors:

Errors:
Profile
:heavy_multiplication_x: The relation field avatar must specify a @relation directive: @relation(name: "MyRelation")
:heavy_multiplication_x: The relation field images must specify a @relation directive: @relation(name: "MyRelation")
:heavy_multiplication_x: The relation field video must specify a @relation directive: @relation(name: "MyRelation")
Document
:heavy_multiplication_x: The relation field front must specify a @relation directive: @relation(name: "MyRelation")
:heavy_multiplication_x: The relation field back must specify a @relation directive: @relation(name: "MyRelation")

Then setting the relations:

type PrimaryProfile @embedded {
  avatar: File @relation(name: "PrimaryProfileAvatar")
  images: [File!] @relation(name: "PrimaryProfileImag")
  video: File @relation(name: "PrimaryProfileVideo")
  document: Document
}
type Document @embedded {
  type: DocumentType!
  front: File @relation(name: "DocumentFront")
  back: File @relation(name: "DocumentBack")
}

Errors above go away, but this time I get errors in /_admin:

[
{
“message”: “Cannot query field ‘id’ on type ‘File’. (line 9, column 7):\n __id: id\n ^”,
“locations”: [
{
“line”: 9,
“column”: 7
}
]
},
{
“message”: “Cannot query field ‘id’ on type ‘PrimaryProfile’. (line 15, column 7):\n __id: id\n ^”,
“locations”: [
{
“line”: 15,
“column”: 7
}
]
},
{
“message”: “Cannot query field ‘id’ on type ‘SecondaryProfile’. (line 20, column 7):\n __id: id\n ^”,
“locations”: [
{
“line”: 20,
“column”: 7
}
]
}

Putting ids doesn’t make any sense to me, since those are supposed to be embedded types. So, I don’t know how to solve this and I’d appreciate for help.

package.json:

{
  "dependencies": {
    "graphql": "^14.1.1",
    "graphql-shield": "^5.3.1",
    "graphql-yoga": "^1.17.4",
    "nexus": "^0.11.4",
    "nexus-prisma": "^0.3.5",
    "prisma-client-lib": "^1.29.0-beta.9"
  }
}

docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.29-beta
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        managementApiSecret: secret
        port: 4466
        databases:
          default:
            connector: mongo
            uri: mongodb://prisma:prisma@mongo
  mongo:
    image: mongo:3.6
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: prisma
      MONGO_INITDB_ROOT_PASSWORD: prisma
    ports:
      - "27017:27017"
    volumes:
      - mongo:/var/lib/mongo
volumes:
  mongo:

prisma.yml:

endpoint: http://localhost:4000
datamodel:
    - ./datamodels/user.prisma
databaseType: document
generate:
  - generator: typescript-client
    output: ../src/generated/prisma-client/
hooks:
  post-deploy:
    - prisma generate
    - yarn nexus

#2

I have the same issue. Did you get it fixed? How?


#3

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.