neo4j-graphql / neo4j-graphql-js

NOTE: This project is no longer actively maintained. Please consider using the official Neo4j GraphQL Library (linked in README).
Other
608 stars 148 forks source link

How do I _force_ a field to be returned #604

Open jruts opened 3 years ago

jruts commented 3 years ago

Hi,

I am currently experimenting with this library but I ran into an issue/question that I need some help with to get a better understanding.

I want to present the question with a simple example.

Here is a graphql query snippet that is connected to a neo4j database

{
  Product{
     name
   }
}

It's fairly simple, get me all names of the products in neo4j with the Product label, and that works.

Here is where it gets tricky

{
  Product{
    name
    description
  }
}

The description is something I need to fetch from another source, so I am writing a custom resolver for that, which is not an issue. The issue is that it depends on the _productno field of the product in neo4j. I can easily just add this field into the query and receive it, and it will be available in the resolver to get the description from the other source.

The question here is: is there a way to always get certain query fields back even without specifying them into the query? In this case I always want the product_no to be returned in the resolver, even if I don't want to return it to the person who is not querying for it.

I hope that made some sense and thank you for reading through it!

michaeldgraham commented 3 years ago

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