Git Product home page Git Product logo

graphql-django-view's People

Contributors

benblippar avatar jhgg avatar syrusakbary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

graphql-django-view's Issues

Batched Requests

Assuming you have these two queries:

First Route makes this query:

{
  viewer {
      items(first: 10) {
        edges {
          node {
           id
           title
          }
        }
      }
  }
}

Second Route makes this query:

{
  viewer {
      items(first: 10) {
        edges {
          node {
           id
           title
           description
          }
        }
      }
  }
}

with the default relay network layer, you will end up with 10 (n) node requests like so:

node(id: *id) {
  description
}

This is bad. So, the wonderful @nodkz wrote a great network layer, that when paired with some express-js middleware, handles batching.

That's wonderful if we (the collective python graphql users) were using express-js, but alas we are not so we need to implement a solution for such.

The JS implementation can be found here:

https://github.com/nodkz/react-relay-network-layer/blob/master/src/express-middleware/graphqlBatchHTTPWrapper.js

I plan to take a first pass at this tomorrow, but figured I would share with the public in case this has been on anyone else's mind.

No support for unicode characters if json content-type

        elif content_type == 'application/json':
            try:
                request_json = json.loads(request.body.decode())
                assert isinstance(request_json, dict)
                return request_json
            except:
                raise HttpError(HttpResponseBadRequest('POST body sent invalid JSON.'))

i believe this code should be refactored

Plugins bypassed since graphql 0.5.0 update

This may be an issue with other execution paths in graphene as well.

It seems that schema plugins (such as the DjangoDebugPlugin) only work if you call schema.execute - they are not called if you use graphql-django-view.

Raise exception on unrecognized Content-Type

https://github.com/graphql-python/graphql-django-view/blob/master/graphql_django_view/__init__.py#L93 will tell the user:

<HttpResponseBadRequest status_code=400, "application/json">
b'{"errors":[{"message":"Must provide query string."}]}'

if the content-type is unexpected. An informative exception should be raised instead, eg:

raise HttpError(HttpResponseBadRequest('Unrecognized content-type: text/plain. Please send one of [application/graphql, application/json, application/x-www-form-urlencoded, multipart/form-data]'))

No support for multipart/form-data

Currently, query is not parsed if the content_type is multipart/form-data.

Submitting a PR to handle this case. Uploaded files should then be accessible in mutate_and_get_payload in info.request_context.POST[filename]

Get middleware, before passing it to GraphQL-Core executor

In this line 96[https://github.com/graphql-python/graphql-django-view/blob/master/graphql_django_view/init.py#L96] it seens that we should get middlewares from self.schema and pass it as parameter to execute (from graphql-core[https://github.com/graphql-python/graphql-core/blob/features/next/graphql/execution/executor.py#L27])

set cookie

How can i set cookie through HttpReponse? for exmaple:

response = HttpReponse('something')
reponse.set_cookie('my_cookie', 'cookie_value')
return reponse

Uncaught errors can not be easily logged

Either using django's logger or through some hook there needs to be a way that things like sentry can know about these uncaught exceptions.

Issue is primarily in graphql_django_view/__init__.py in dispatch() of GraphQLView

except HttpError as e:
            response = e.response
            response['Content-Type'] = 'application/json'
            response.content = self.json_encode(request, {
                'errors': [self.format_error(e)]
            })
            return response

Cannot access request within mutation

I am creating a new model within a mutation. I would like to set the model's created_by field to point to the current user (using request.user). However, AFAIK the request object is not available within a mutation's mutate_and_get_payload() method.

Note: It is entirely possible that I'm going about this the wrong way, I'm still new to GraphQL.

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.