longclawshop / longclaw

A shop for Wagtail CMS
MIT License
392 stars 83 forks source link

GraphQL API #52

Open JamesRamm opened 7 years ago

JamesRamm commented 7 years ago

Exposing a graphql API (using graphene) would be useful and make for a richer experience when making react-based apps. I think it should be optional (enabled in the settings) so that extra dependencies are are only required if it is enabled.

alexfromvl commented 7 years ago

Hi. Is there any work on this block?

JamesRamm commented 7 years ago

@alexfromvl Not as yet; I'm just taking a little break from longclaw at the moment. I plan to start adding more commits from the end of the month.

Having said that, I think this issue is not a priority yet. I welcome PR's on it!

alexfromvl commented 7 years ago

@JamesRamm Hi. I made changes to the project https://github.com/alexfromvl/longclaw, so you can connect GraphQL API. I am now testing the stability. I'm not going to add changes to the main branch, but if these changes are enough to get started with GraphQL, notify and I will make PR.

JamesRamm commented 7 years ago

@alexfromvl Ive had a brief look at the changes and just have the following comment:

The api folder which contains the graphql schema shouldn't be within project_template. project_template is just a scaffolding to help get quickly setup with a new project. Actual enhancements/changes to longclaw should go outside it.

Whether there should be a schema.py in each longclaw app or a separate longclawgraphql app - I'm not sure and am open to good suggestions! Although I think it is important that graphql/graphene is supported as an optional requirement. With that constraint there may be only 1 ideal solution.

alexfromvl commented 7 years ago

@JamesRamm Thanks for the comment. To make a separate connection GraphQL as an application is an appropriate solution. Question schema.py depends on what you will need to specify the model pages for the query.

I think in this case it is possible to act on the principle of import module, which picks up the settings (settings are defined in a separate class models.py) import longclawgraphql and launches the desired logic Graphene. I will try in the near future to bring this idea into the final code.

JamesRamm commented 7 years ago

@alexfromvl Hey, have you managed to get any further with this? If you want to make a PR with what you have already got, then we can work toward getting it merged.

alexfromvl commented 7 years ago

@JamesRamm Hi. I will try until the end of this week to make all the necessary changes and make PR.

alexfromvl commented 7 years ago

@JamesRamm After many attempts, found out that to implement the functionality GraphQL as a standalone application longclawgraphql does not work. Each application still needs the file schema.py and a common control file to customize Graphene.

JamesRamm commented 6 years ago

@alexfromvl Ok, I'll have a think about how best to tackle this

janbaykara commented 2 years ago

Potentially this could be done with https://github.com/torchbox/wagtail-grapple