simonw / datasette-graphql

Datasette plugin providing an automatic GraphQL API for your SQLite databases
https://datasette-graphql-demo.datasette.io/
Apache License 2.0
100 stars 6 forks source link

Support returning arbitrary JSON from a field #53

Closed simonw closed 4 years ago

simonw commented 4 years ago

GraphQL doesn't really like this - it wants everything to be in the schema. But Datasette and SQLite both support columns with arbitrary JSON in them, and it's a bit inconvenient that those come back from a GraphQL query looking like this:

GraphiQL

Graphene has a solution for this: https://github.com/graphql-python/graphene/issues/384

from graphene.types import generic
...
field generic.GenericScalar()

Question is: how do we know which columns this should be applied to? Probably needs plugin configuration.

simonw commented 4 years ago

Documentation: https://github.com/simonw/datasette-graphql/blob/56bac67ce2839693723e41919075d7d75e9cb969/README.md#columns-containing-json-strings

simonw commented 4 years ago

Demo: https://datasette-graphql-demo.datasette.io/graphql/fixtures?query=%7B%0A%20%20repos%20%7B%0A%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20tags%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A

GraphiQL