I keep getting a request error: 'Request' object has no attribute 'get'
See original GitHub issuepython 3.6 pipenv ubuntu 16.04 mysql 5.7
my packages:
[packages]
flask-graphql = "*"
flask-sqlalchemy = "*"
sqlalchemy-fulltext-search = "*"
graphene-sqlalchemy = ">=2.0"
flask-restful = "*"
flask-marshmallow = "*"
sqlalchemy-pagination = "*"
my code:
from graphene import ObjectType, Schema, relay, Field
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from app.domain.model import Material, Grupo, Classe, Pdm
class MaterialType(SQLAlchemyObjectType):
class Meta:
model = Material
interfaces = (relay.Node, )
class PdmType(SQLAlchemyObjectType):
class Meta:
model = Pdm
interfaces = (relay.Node,)
class ClasseType(SQLAlchemyObjectType):
class Meta:
model = Classe
interfaces = (relay.Node, )
class GrupoType(SQLAlchemyObjectType):
class Meta:
model = Grupo
interfaces = (relay.Node, )
class Query(ObjectType):
node = relay.Node.Field()
materiais = SQLAlchemyConnectionField(MaterialType)
pdms = SQLAlchemyConnectionField(PdmType)
classes = SQLAlchemyConnectionField(ClasseType)
grupos = SQLAlchemyConnectionField(GrupoType)
material = Field(GrupoType)
pdm = Field(PdmType)
classe = Field(ClasseType)
grupo = Field(GrupoType)
schema = Schema(query=Query, types=[MaterialType, PdmType, ClasseType, GrupoType])
import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from app.domain.model import Base
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = connection_string
db = SQLAlchemy(app, metadata=Base.metadata)
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
my error:
An error occurred while resolving field Query.materiais
Traceback (most recent call last):
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphql/execution/executor.py", line 311, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphql/execution/executors/sync.py", line 7, in execute
return fn(*args, **kwargs)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphene_sqlalchemy/fields.py", line 36, in connection_resolver
iterable = cls.get_query(model, info, **args)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphene_sqlalchemy/fields.py", line 20, in get_query
return get_query(model, info.context)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphene_sqlalchemy/utils.py", line 13, in get_query
session = get_session(context)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphene_sqlalchemy/utils.py", line 7, in get_session
return context.get('session')
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'get'
Traceback (most recent call last):
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphql/execution/executor.py", line 330, in complete_value_catching_error
exe_context, return_type, field_asts, info, result)
File "/home/jhon/.local/share/virtualenvs/crm_api-CGOvMSyN/lib/python3.5/site-packages/graphql/execution/executor.py", line 383, in complete_value
raise GraphQLLocatedError(field_asts, original_error=result)
graphql.error.located_error.GraphQLLocatedError: 'Request' object has no attribute 'get'
Am i doing something wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:13 (1 by maintainers)
Top Results From Across the Web
'Request' object has no attribute 'get' Python error
You want to use request.args for your GET parameters in Flask. Here is a quote with an example from the Accessing Request Data...
Read more >R = request.get(url) attributeerror: 'request' object has no ...
Solution 1. Accept Solution Reject Solution. You do not show which is line 15, but I cannot see a line like:.
Read more >The Request Context — Flask Documentation (0.12.x)
redirect_url() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'NoneType' object has no attribute 'request'.
Read more >RDP libraries: 'Request' object has no attribute 'prepare' - Forum
Hi. I am working with a client that has a free trial for ERT Cloud and they are getting the following error message...
Read more >Error "'NoneType' object has no attribute 'get'" when executing ...
Error "'NoneType' object has no attribute 'get'" when executing runbook via API · You have to set the Context-Type to application/json . With ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is an issue with db session, I also had the same issue.
I wish you had posted your models here also so that see how you’ve set up your Base object.
The key to solving your issue is this…
Base.query = db_session.query_property()it seems get_context also works for flask-graphql
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True, get_context=lambda: {'session':Session()}))the Session() func retrives SqlalchemySession from
g(my custom function)