cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How do I update my GraphQL schemas directly from neo4j?

I'm using the GraphQL plugin for my Neo4j Desktop (https://github.com/neo4j-graphql/neo4j-graphql) and it was working great until recently. I realized I needed a new relationship between two different node types, and after I ran the cypher to create the new relationships in the database, I restarted the database/server via the Neo4j Desktop app, but I'm not seeing any update to the schema (which I'm accessing via GraphiQL on my desktop.

Any ideas about what I should do, or can you point me to resources I should read before bugging people here. I'm not a very sophisticated developer, so it's not entirely unlikely I'm missing something obvious.

I have run: call graphql.idl(null) a couple of times

thanks in advance!

8 REPLIES 8

Just for future reference, GraphQL != GQL, since GQL is the name of the Graph Query Language initiative to create a standard graph query language.

Thanks, I appreciate the heads up, although at this point it seems like name collision is a thing. After all, GraphQL stands for Graph Query Language.

William_Lyon
Graph Fellow

Hey @daniel.harrison -

If you run RETURN graphql.getIdl() do you see the new relationships in the type definitions?

You can also explicitly add to the GraphQL type definitions by taking the result of RETURN graphql.getIdl(), modifying it to include the relationship fields you want to add and sending those new type definitions (as a string) in CALL graphql.idl(<TYPE DEFS HERE>)

Thanks @William_Lyon. I enjoyed your video on using the Neo4j-GraphQL plugin with Neo4 desktop, btw.

I'll try that. It seems that vigorous turning it off and turning it on again has helped a bit, since I can now get some of the new relationships. I'm still having difficulty getting it to return an array of objects rather than a single object when it's a many-to-many relationship, but I'll keep at it. Thanks for the suggestions.

Hi @William_Lyon, I tried your idea of getting the schema, fixing it in my editor, and returning it to the graphQL server, but am running into some errors.

One of the main changes I want to make is turning a linked item from a one-to-many into a many-to-many relationship. If, let's say, "employs" is a property of the Company type, can I just throw some square brackets around the word Person at the end of the employs property like go from "...): Person" to "... 😞 [Person]"? Or is there more I'll have to do?

I don't want to make you explain GraphQL or anything else that's fairly well documented, so any links you can provide would be much appreciated. On which topic, if you've got a list of the procedures I can call on the graphql plugin, it'd be a great help.

thanks!

@William_Lyon, I've been reading a lot of your tutorials and notes on this tool, and thank you for it! I can't work out if there's a way to update portions of the schema.

Also, I'm still not getting it to work when I upload a new schema with the changes I want. Is there a cache I have to dump or something else I might be missing?

Thanks again!

Hey @daniel.harrison - if you're using the database plugin you'll need to pass the entire schema each time you run CALL graphql.idl(...), there is not an option for partially updating the type definitions.

Do you have the most recent version of the plugin (v3.5.0.4)? There was an improvement for handling updates to the type definitions.

Hi @William_Lyon, thanks for the reply. I'm finally getting back to this and could use a little advice.

First, I am on v3.5.0.4 of the plugin. Also using v3.5.6 of neo4j in desktop.

Next, per your suggestion, I pulled down the existing schema using RETURN graphql.getIdl(), then opened the results in vscode and basically made the smallest change I could, which was to add brackets around a type definition. In this section of the schema definition:

#Technology usedTechnology Project
  usedTechnology(
    #cost_code of Project
    cost_code: String, 
    #cost_codes is list variant of cost_code of Project
    cost_codes: [String], 
    #description of Project
    description: String, 
    #descriptions is list variant of description of Project
    descriptions: [String], 
    filter: _ProjectFilter, 
    #id of Project
    id: Long, 
    #ids is list variant of id of Project
    ids: [Long], 
    #name of Project
    name: String, 
    #names is list variant of name of Project
    names: [String], 
    orderBy: [_ProjectOrdering], 
    #repository of Project
    repository: String, 
    #repositorys is list variant of repository of Project
    repositorys: [String], 
    #status of Project
    status: String, 
    #statuss is list variant of status of Project
    statuss: [String]
  😞 Project
}

I took the second to last line and made it 😞 [Project] instead of 😞 Project

Then I grabbed the whole definition from VSCode and pasted in as an argument of CALL graphql.idl()

Unfortunately, when I went back and used RETURN graphql.getIdl(), I got the following error:

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke function graphql.getIdl: Caused by: java.lang.IllegalArgumentException: Unknown field type _ProjectFilter

Any direction you can give me would be much appreciated. I recognize I may be making some very dumb mistakes, and if so, please let me know.

Thanks!