Code Monkey home page Code Monkey logo

flask-graphene-sqlalchemy's Issues

Querying by column values?

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

How to enable cors

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

Thanks for the everything but still need some more help please

@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.

image

Can you please let me know what I should be doing in this case ?

Thanks once again.

With Regards
Gagan

Input Type Problems

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.