0

The following JSON has quotes around the integers, and I need these gone (observe the rRegionkey):

{
  "data": {
    "regionsAll": {
      "edges": [
        {
          "node": {
            "rComment": "hs use ironic, even requests. s",
            "rName": "AMERICA",
            "rRegionkey": "1"
          }
        },
        {
          "node": {
            "rComment": "ges. thinly even pinto beans ca",
            "rName": "ASIA",
            "rRegionkey": "2"
          }
        }
      ]
    }
  }
}

This JSON comes from the following stack, all the latest versions:

  • GraphiQL. Within a browser, I hit the usual /graphql end point.
  • Flask. As the web app server.
  • Graphene. This is the GraphQL library. Including the graphene_sqlalchemy library.
  • SQLAlchemy. Used as the ORM to the database.
  • PostgreSQL. As the database. The region key is an integer as shown below.

Somewhere in this stack, the integer in PostgreSQL turns into a quoted string in the JSON. Where? What setting can I set to get rid of the quotes?

Just to confirm, the \d of the table in PostgreSQL is here (observe the type of r_regionkey):

   Column    |          Type          | Collation | Nullable | Default
-------------+------------------------+-----------+----------+---------
 r_regionkey | integer                |           | not null |
 r_name      | character varying(25)  |           | not null |
 r_comment   | character varying(152) |           |          |

At the ORM level, I'm pulling it in as an Integer(observe again r_regionkey):

class Region(Base):

    __tablename__  = 'h_region_int'
    __table_args__ = {'autoload': True}

    r_name         = Column(String, doc='The company name for the region.')
    r_regionkey    = Column(Integer, primary_key=True, doc='Identifier for the region.')
    r_comment      = Column(String, doc='Extended information about the region.')

As I move into Graphene, I don't mess with the column level at all:

class Region(SQLAlchemyObjectType):
    class Meta:
        model = RegionModel
        interfaces = (relay.Node, )
        description='A collection of nations around the world.'

By the time I'm up to Flask, I'm really just doing sweeping things, not messing with columns:

app.add_url_rule(
    "/graphql",
    view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True)
)

So my question--what obscure setting somewhere along the way do I need to set to get those quotes off my integer data types?

Thanks!

4

0 回答 0