libNeuroML icon indicating copy to clipboard operation
libNeuroML copied to clipboard

libNeuroML and GraphQL and generateDS.py

Open dkuhlman opened this issue 2 years ago • 1 comments

This an announcement of a feature, as opposed to a request for one.

I have added generateDS.py the ability to generate Python modules that implement a Strawberry GraphQL server. So, you can generate the implementation of a GraphQL API from the NeuroML XML schema. I'm guessing that there are problems hidden in it, but my testing so far shows that it works. I used it to generate a module from NeuroML_v2.2.xsd and now I can make GraphQL queries into the XML instance docs in the repo examples directory.

Here is what it did to test it:

(1) Generate the module:

#!/usr/bin/bash -x
./generateDS.py \
    -f \
    -o tmp01.py \
    --graphql="neuroml:NeuroMLDocument" \
    ../Git/NeuroML2/Schemas/NeuroML2/NeuroML_v2.2.xsd

(2) Run the Strawberry server:

#!/usr/bin/bash -x
GRAPHQL_ARGS=examples/NML2_FullCell.nml strawberry server tmp01

See the following for more info:

  • http://www.davekuhlman.org/generateDS.html#graphql-support
  • https://strawberry.rocks/docs
  • https://graphql.org/

If you have comments, please pass them along.

Dave

dkuhlman avatar Jul 14 '23 21:07 dkuhlman

Thanks @dkuhlman , that looks very interesting + useful. We'll give it a go and provide any feedback we can come up with.

sanjayankur31 avatar Jul 22 '23 09:07 sanjayankur31