Skip to content

apollo-server, neo4j-graphql, and schema extraction #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neurofoo opened this issue Jul 28, 2017 · 9 comments
Closed

apollo-server, neo4j-graphql, and schema extraction #40

neurofoo opened this issue Jul 28, 2017 · 9 comments

Comments

@neurofoo
Copy link

posting this as an issue per @jexp request in slack

It would be great if neo4j-graphql and apollo-server would place nice with each other.

Writing schema in neo4j-graphql is a breeze! But apollo-server requires a local version of the schema as well as resolvers. So, one winds up with an impedance mismatch because you can just directly send graphql queries to neo4j via the plugin, which obviates apollo-server's resolvers.

With that in mind...

Does anyone know if you can get the generated cypher queries from the plugin?

Related question, does the plugin generate all the queries and then stores them, or does the plugin just generate the queries on the fly? If the latter, then I expect it wouldn’t be possible to get the queries.

The reason I ask is that I’m working with a backend that is using the apollo-server. It would be nice if the plugin could spit out the queries, which I could then use in the apollo-server resolvers.

Thanks!

@johnymontana
Copy link
Contributor

Thanks for the feedback. As you point out, in its current form neo4j-graphql is more of a replacement for apollo-server than a complementary tool since Neo4j is serving the GraphQL endpoint. We've had similar requests so we're working on a separate library for generating Cypher queries from GraphQL that would work with apollo-server.

The Cypher queries are generated on the fly for a given GraphQL query. I don't believe they are currently logged, but we could add support for that. You could also enable query logging in Neo4j to see what queries are being executed

@neurofoo
Copy link
Author

neurofoo commented Aug 3, 2017

@johnymontana many thanks! I'll look into the logging for current dev. I'm looking forward to seeing this project advance!

@linonetwo
Copy link

@johnymontana To work with Apollo GraphQL, do you mean cascading GraphQL endpoint?

FYI graphql/graphql-js#490

@Joshfindit
Copy link

Possibly related:
Do we have a way to modify a schema file on-disk?

I went looking for one, but can't see where neo4j-graphql stores it's config.

@jexp
Copy link
Contributor

jexp commented May 29, 2018

it stores it in the graph itself as a graph property, so it's e.g. synched across a cluster.

@jexp
Copy link
Contributor

jexp commented Jun 28, 2018

@Joshfindit You could just re-post your IDL if you have changes.
Or what would be the change you would like to make?

@Joshfindit
Copy link

@jexp Sorry, that was a while ago. I wasn't able to get my hands on it deeply enough and couldn't commit to using it for real data so I have no idea what I was working with at that time.

Reading back it seems like it might be helpful to share the query that returns the schema.

@jorroll
Copy link
Contributor

jorroll commented Sep 15, 2018

I think this issue can be closed.

Using apollo-cli, you can download an introspection query of the neo4j auto-generated schema in json form. You can then feed this into Apollo server using makeRemoteExecutableSchema. Using the schema transform functions in graphql-tools, you can merge the Neo4j schema into your ApolloServer schema, the apollo server schema is then smart enough to delegate resolution of fields to Neo4j, as appropriate.

This solution also allows you hide Neo4j schema fields from the public or to add additional logic before and after Neo4j field resolution. For example, you can remove/add query arguments, perform authorization checks, etc.

Update

I may have gotten ahead of myself. It turns out one of the major limitations of schema stitching is that you cannot modify the query very much if you are forwarding it to the neo4j-graphql plugin. This is a shame, because it largely eliminates the ability to wrap neo4j fields from the neo4j schema with authorization checks.

@jexp
Copy link
Contributor

jexp commented Sep 15, 2018

@thefliik it sounds as if there is a blog post from you waiting showing how to do this in detail :)

We'd be happy to publish it at blog.grandstack.io but you could also submit it to freecodecamp or hackernoon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants