graphql-python / graphene

GraphQL framework for Python

Home Page:http://graphene-python.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Distinct on a single field

ArjunSrR opened this issue · comments

Hi
I am new to graphql, I have n column want to apply distinct on a single column based on query input and return that alone using graphene. Is that possible?

This is not a bug, but a question, which I do not understand. You need to be more precise. Note there is no concept of "column" in Graphene. Sounds more like a database related question.

This is not a bug, but a question, which I do not understand. You need to be more precise. Note there is no concept of "column" in Graphene. Sounds more like a database related question.

Hi, Thanks for your reply.

I am using python to setup GraphQL server, I have a DB and I am connecting it through SQL Alchamey . I am using SQLAlchemyConnectionField(from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
)
I get some builtin for sort and pagination. Now I am implementing "DISTINCT"

If I use (files_query.order_by(*sort).distinct()), I can resolve and get distinct query that applied on all field those are declared as models.

Ex: SELECT DISTINCT

But I need to apply DISTINCT on a particular field instead of applying on all fields. Is that possible ??

Hey Arjun,
this is the graphene repository.
Apart from issues regarding our integration with SQLAlchemy, graphene-sqlalchemy, we cannot provide support for SQLAlchemy here.
Anyways, this might help you:
https://stackoverflow.com/questions/14105503/sqlalchemy-distinct-only-on-one-column

In the future, please use StackOverflow or the relevant docs of SQLAlchemy for questions not related to graphene or graphene-sqlalchemy.