neo4j-graphql-js icon indicating copy to clipboard operation
neo4j-graphql-js copied to clipboard

Problem with to and from fields on type

Open michal-trnka opened this issue 6 years ago • 2 comments

I can't have fields from and to on types without each other. I believe that it is a bug in makeAugmentedSchema because the schema works fine with Apollo's makeExecutableSchema

minimal schema:

type Focus {
  from: String!
}

type Query {
  randomForRoot(param: String): String
}

type Mutation {
  login(email: String!, password: String!): String!
}

It leads to: Error: Relationship type Focus has a 'from' field but no corresponding 'to' field

Another error is that I can't have following type:

type Focus {
  from: String!
  to: String!
  industries: [Industry!]!
}

which leads to Syntax Error: Expected Name, found }

strange enough I can have this definition:

type Focus {
  from: String!
  to: String!
  random: String
  industries: [Industry!]!
}

or I can have this one:

type Focus {
  fromDate: String!
  toDate: String!
  industries: [Industry!]!
}

michal-trnka avatar Aug 20 '19 12:08 michal-trnka

The from and to fields have special meaning in the context of relationships types (types with the @relation directive). See https://grandstack.io/docs/graphql-relationship-types.html#relationships-with-properties

It looks like we might be treating any field named to and from on any type as one of these special fields, even if it is not a relationship type. At a minimum we should verify the type has a @relation directive before treating it as one of these special fields.

johnymontana avatar Aug 28 '19 19:08 johnymontana

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608

michaeldgraham avatar May 02 '21 04:05 michaeldgraham