simonw / datasette-graphql

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

Name '__index' must not begin with '__', which is reserved by GraphQL introspection #91

Closed simonw closed 1 year ago

simonw commented 1 year ago

Seeing this error here:

https://fivethirtyeight.datasettes.com/graphql/fivethirtyeight?query=%7B%0A%20%20generic_ballot_polls(filter%3A%7Bpollster_rating_name%3A%7Beq%3A%22YouGov%22%7D%7D)%20%7B%0A%20%20%20%20totalCount%0A%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20pollster%0A%20%20%20%20%20%20sponsor_ids%0A%20%20%20%20%20%20sponsors%0A%20%20%20%20%20%20partisan%0A%20%20%20%20%20%20display_name%0A%20%20%20%20%20%20pollster_rating_name%0A%20%20%20%20%20%20fte_grade%0A%20%20%20%20%20%20population%0A%20%20%20%20%20%20population_full%0A%20%20%20%20%20%20methodology%0A%20%20%20%20%20%20office_type%0A%20%20%20%20%20%20start_date%0A%20%20%20%20%20%20end_date%0A%20%20%20%20%20%20tracking%0A%20%20%20%20%20%20created_at%0A%20%20%20%20%20%20notes%0A%20%20%20%20%20%20url%0A%20%20%20%20%20%20stage%0A%20%20%20%20%20%20dem%0A%20%20%20%20%20%20rep%0A%20%20%20%20%20%20ind%0A%20%20%20%20%20%20question_id%0A%20%20%20%20%20%20poll_id%0A%20%20%20%20%20%20cycle%0A%20%20%20%20%20%20state%0A%20%20%20%20%20%20pollster_id%0A%20%20%20%20%20%20pollster_rating_id%0A%20%20%20%20%20%20sample_size%0A%20%20%20%20%20%20seat_number%0A%20%20%20%20%20%20sponsor_candidate%0A%20%20%20%20%20%20nationwide_batch%0A%20%20%20%20%20%20rowid%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A

image
simonw commented 1 year ago

Found the source of the error here: https://github.com/graphql-python/graphql-core/blob/619a77a7d79415aca63da5d7070249ed0a7ac3b5/src/graphql/type/validate.py#L192

            if name.startswith("__"):
                self.report_error(
                    f"Name {name!r} must not begin with '__',"
                    " which is reserved by GraphQL introspection.",
                    ast_node,
                )
simonw commented 1 year ago

One of the causes of this is https://fivethirtyeight.datasettes.com/fivethirtyeight/pollster-ratings~2Fpollster-ratings which has a column called:

  "# of Polls for Bias Analysis" INTEGER,
simonw commented 1 year ago

I'm going to try turning a prefix __ into _0_.