alexisrolland / flask-graphene-sqlalchemy Goto Github PK
View Code? Open in Web Editor NEW⚗️Project template to build a GraphQL API in Python
License: Apache License 2.0
⚗️Project template to build a GraphQL API in Python
License: Apache License 2.0
Thanks for this great tutorial. I only wish it would have shown how to query the data by specific column values. For example, show me a planet of a given name or all the planets with gravity > X.
Regards,
Alvaro
before use flask_graphql:
@app.route('/api/currentUser/')
def currentUser():
jsonStr = '{"name":"XXX","avatar":"XXX","userid":"00000001","notifyCount":12}'
res = flask.Response(jsonStr)
res.headers['Access-Control-Allow-Method'] = 'GET,POST,OPTIONS,DELETE,PUT'
res.headers['Access-Control-Allow-Origin'] = '*'
return res
after user flask_graphql:
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql = True, context={'session': db_session}))
And I do not know how to enable CORS
@alexisrolland , thank you for everything. I really liked the Wiki page which was extremely thorough. Much appreciated!!
That said, I have a doubt as well.
Please consider the following use case.
There is a post
model as well as a tag
model. Both of them have a many to many relationship between them. A post
can have multiple tags
while a tag
can have multiple posts
.
In order to attain this use case, I have implemented a mapping
table called, PostTag
and it looks like as follows
from database.base import Base
from sqlalchemy import Column, ForeignKey, Integer
from sqlalchemy.orm import relationship
from .model_post import ModelPost
from .model_tag import ModelTag
class PostTag(Base):
__tablename__ = 'posttag'
post_id = Column("post_id",Integer, ForeignKey('post.id'), primary_key = True)
tag_id = Column("tag_id",Integer, ForeignKey('tag.id'), primary_key = True)
Now, I dont know how to update my schema in such a manner that I can get a tagList
when I query for it. Notice that in the screenshot below, there is no tagList
and an error is being displayed on the screen. This is happening when I am querying for all the posts
related data.
Can you please let me know what I should be doing in this case ?
Thanks once again.
With Regards
Gagan
I've been having trouble understanding why I am getting an error along the lines of
AssertionError: Mutation.createAddress(input:) argument type must be Input Type but got: CreateAddressInput!.
My schema snippet is as follows:
class AddressAttribute(graphene.ObjectType):
street_number = graphene.Int(description='Street Number of Dealership Address', required=True)
street_name = graphene.String(description='Street Name of Dealership Address',required=True)
city_name = graphene.String(description='City Name of Dealership Address',required=True)
county_name = graphene.String(description='County Where Dealership is Located', required=False)
state_code = graphene.String(description='Two Letter State Code Where Dealership is Located', required=True)
postal_code = graphene.String(description='Postal Code Where Dealership is Located', required=True)
dealership_id = graphene.ID(description='Global ID of the dealership which the address belongs')
class CreateAddressInput(graphene.InputObjectType, AddressAttribute):
"""Arguments to create an address."""
pass
Any help would be appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.