graphql-python / aiohttp-graphql Goto Github PK
View Code? Open in Web Editor NEWAdds GraphQL support to your aiohttp app.
License: Other
Adds GraphQL support to your aiohttp app.
License: Other
Hi! I'm using python 3.5.3.
This line cause SyntaxError: invalid syntax exception because of trailing comma.
I think it should be removed for compatibility with older python versions.
Thank you!
related issue: graphql-python/graphql-server#32
workaround: use `graphql-server-core<=1.1.1'
The deps in setup.py pull in graphl-server-core>=1.0.dev which pulls in the 1.1rc0 but keeps graphql-core at 2.0. graphql-server-core 1.1rc0 and graphql-core 2.0 are incompatible. This breaks aiohttp-graphql.
It is probably not a good idea to define such a wide range for dependencies on core graphql libs so this won't happen again.
Workaround for now is to downgrade graphql-server-core in my project to graphql-server-core==1.0.dev20170322001
When trying to connect to the graphql endpoint with Apollo, the following error occurs:
Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
However curl pulls just well:
curl -X POST -H "Content-Type: application/json" --data '{"query": "{hello}"}' http://randomhost/graphql
{"data":{"hello": "world"}}
Attached as such:
app = web.Application()
GraphQLView.attach(app, schema=schema, executor=AsyncioExecutor(loop=app.loop), graphiql=True)
Update:
Tried to create a child for GraphQLView as such:
class GQLView(GraphQLView):
def process_preflight(self, request):
""" Preflight request support for apollo-client
https://www.w3.org/TR/cors/#resource-preflight-requests """
headers = request.headers
origin = headers.get('Origin', '')
method = headers.get('Access-Control-Request-Method', '').upper()
accepted_methods = ['GET', 'POST', 'PUT', 'DELETE']
if method and method in accepted_methods:
return web.Response(
status=200,
headers={
'Access-Control-Allow-Origin': origin,
'Access-Control-Allow-Methods': ', '.join(accepted_methods),
'Access-Control-Max-Age': str(self.max_age),
'Access-Control-Allow-Headers': "Content-Type"
}
)
return web.Response(status=400)
When using this, I can see the query hits the server (packet capture), and I get this error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
After this patch: graphql-python/graphql-server@ad392b5 GraphqiQL is not rendered on GET requests even if configured with graphiql=True
Current version available on PyPI requires graphql-core>=2.0.dev
. Because of this I have to put restriction graphql-core<3
in my project.
This was fixed in code, but not published yet.
Hello!
Is there any plan to update graphql-core and graphql-server-core dependencies to the latest version?
I want to be able to async/await for a mutate method
class UploadFileMutation(graphene.ClientIDMutation):
class Input:
pass
ok = graphene.Boolean()
@classmethod
async def mutate_and_get_payload(cls, root, info, **input):
# do something with your file
return UploadFileMutation(ok=True)
Is this not possible?
The server just kind of hangs
Also with query
class SearchableQuestionPair(graphene.ObjectType):
question = graphene.String(required=True)
answer = graphene.String(required=True)
class SearchInput(graphene.InputObjectType):
_input = graphene.String(name="input", argument=graphene.String(), description="Text to search for")
class RootQuery(graphene.ObjectType):
searchable_question_pairs = graphene.List(SearchableQuestionPair, argument=SearchInput(required=True))
ok = graphene.Boolean(default_value=True)
async def resolve_searchable_question_pairs(self, info, argument):
return [SearchableQuestionPair(question="foo", answer="bar"),
SearchableQuestionPair(question="buzz", answer="zap")]
So this can also be used as a GraphQL client, using the client functionality in aiohttp
? Can you provide an example of how this is used?
Would be a nice addition to the main README.md
Hi there, are there any plans to release verseion 1.1.x?
There are several scripts and a stylesheet included in aiohttp_graphql/render_graphiql.py
for the domain cdn.jsdelivr.net
. The use of this CDN prevents the graphiql interface from being used offline.
The same issue was seen here graphql/graphiql#676
The entire bundle is about +725k to add directly to the package.
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.