Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Relationship with properties doesn't build with interface types. #142

Closed
purplemana opened this issue Nov 12, 2018 · 4 comments · Fixed by #481
Closed

Relationship with properties doesn't build with interface types. #142

purplemana opened this issue Nov 12, 2018 · 4 comments · Fixed by #481
Labels
Interface Issues relating to Interface types and InlineFragments

Comments

@purplemana
Copy link

Relationships with properties don't build if they are linked to an interface and its implemented types.

Given a schema like this...

# Binary document content details
type DocumentContent {
  # Reference ID of the content
  contentRefId: ID!
  # Document file name
  fileName: String!
  # Document mimeType
  mimeType: String!
  # Document encoding
  encoding: String!
  # Content Checksum
  checksum: String!
  # Uploaded By
  uploadedBy: Uploads!
}

# Uploaded Documents
type Uploads @relation(name: "UPLOADED"){
  from: User!
  to: DocumentContent
  on: String!
}

interface User {
  id: ID!
  email: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
  uploadedDocuments: [Uploads]
}

type CustomUser implements User {
  id: ID!
  email: String!
  password: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
  uploadedDocuments: [Uploads]
}

type LdapUser implements User {
  id: ID!
  userName: String!
  email: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
  uploadedDocuments: [Uploads]
}

augmentSchema and makeAugmentedSchema throw the below error:

/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:415
    throw new Error('The \'' + field.name.value + '\' field on the \'' + typeName + '\' type uses the \'' + relatedAstNode.name.value + '\'\n    but \'' + relatedAstNode.name.value + '\' comes from \'' + fromName + '\' and goes to \'' + toName + '\'');
                               ^

ReferenceError: field is not defined
    at validateRelationTypeDirectedFields (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:415:32)
    at handleRelationTypeDirective (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:472:9)
    at handleRelationFields (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:391:21)
    at /mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:86:15
    at Array.forEach (<anonymous>)
    at augmentTypeMap (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augment.js:49:32)
    at makeAugmentedExecutableSchema (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/augmentSchema.js:54:54)
    at makeAugmentedSchema (/mnt/c/Code/neo4j-graphql-exp/node_modules/neo4j-graphql-js/dist/index.js:554:59)
    at Object.<anonymous> (/mnt/c/Code/neo4j-graphql-exp/src/index.js:18:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)

If the type of Uploads relationship is changed to any of the concrete types, then the schema builds, e.g.

# Binary document content details
type DocumentContent {
  # Reference ID of the content
  contentRefId: ID!
  # Document file name
  fileName: String!
  # Document mimeType
  mimeType: String!
  # Document encoding
  encoding: String!
  # Content Checksum
  checksum: String!
  # Uploaded By
  uploadedBy: Uploads!
}

# Uploaded Documents
type Uploads @relation(name: "UPLOADED"){
  from: CustomUser!
  to: DocumentContent
  on: String!
}

interface User {
  id: ID!
  email: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
}

type CustomUser implements User {
  id: ID!
  email: String!
  password: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
  uploadedDocuments: [Uploads]
}

type LdapUser implements User {
  id: ID!
  userName: String!
  email: String!
  fullName: String!
  enabled: Boolean!
  emailVerified: Boolean!
  photoUrl: String
}

But this would mean that with every concrete type which implements User, we will need to define a new Relationship Type.

@aonamrata2
Copy link

Is there a timeline or something on when this feature will be available?
[ ] Handle interface types
[ ] Handle inline fragments
Just wondering if I should wait or do some custom cypher for Production usercase.

@johnymontana johnymontana added the Interface Issues relating to Interface types and InlineFragments label Jun 3, 2019
@burdiyan
Copy link

Having the same issue. Don't know if Neo4j GraphQL Plugin supports this kind of schema. Will try to figure it out.

@burdiyan
Copy link

For some reason in my version of Neo4j Desktop the GraphQL plugin doesn't have "Install" button, but the rest of the plugin do have this button.

Anyway, clearly it doesn't work when relation types are pointing to some interfaces in their from or to fields. But the code doesn't give a clear error, because the code uses undefined variable, that's why it fails with confusing ReferenceError.

On this line https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/src/augment.js#L1071 variable field is not defined.

@anakornk
Copy link

anakornk commented Jul 1, 2020

Any updates on when will this be implemented ?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Interface Issues relating to Interface types and InlineFragments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants