Git Product home page Git Product logo

Comments (3)

colinfindlay avatar colinfindlay commented on June 24, 2024

I think that would be the behaviour I would expect. Reading the documentation though - I think the example is misleading - so I will update it

The filters are applied at the part of the query where the arguments are specified (and its children) it doesn't filter the parent entities. Is that what you are looking to do?

from arangodb-graphql-spring-boot-starter.

gmjordan avatar gmjordan commented on June 24, 2024

The filters are applied at the part of the query where the arguments are specified (and its children) it doesn't filter the parent entities. Is that what you are looking to do?

i am looking filter parents that have children with the same properties

from arangodb-graphql-spring-boot-starter.

colinfindlay avatar colinfindlay commented on June 24, 2024

I think this is a common GraphQL problem - mostly down to how resolvers generally work.

For example:
graphql-python/graphene#431
https://www.prisma.io/forum/t/filter-query-by-field-on-nested-type/1495

One challenge specific to this library with doing this is expressing it as AQL. The current behaviour means that you can have multiple traversals following different edge collections at the same level in your GraphQL

i.e. it would allow me to write something like this where I want the states but also some census information. I haven't applied a filter on country so I expect to get all the countries and their census information.

query{
	findCountry{
	    name
	    states(region:"South"){
	        name
	        region
	    }
            census(year: 2020){
                population
           }
	}
}

The TraversalFilterGenerator generates a filter statement that ties the submitted filter to the edge it was submitted against to allow this to happen. I'm convinced this is a sensible default behaviour as it is in line with how resolvers generally operate.

My advice would be you have two possible ways of achieving the behaviour you want.

One - turn the query on it's head - do this instead:

query{
	findState(region: "South"){
	    name
            region
            country {
                name
            }
	}
}

OR option two, modify the default behavior.

If you want to change the filtering behaviour you can do it by creating a bean of type ArangoQueryGeneratorChain (it uses DefaultArangoQueryGeneratorChain by default) and wiring in your own implementation of an AQL Filter generator by implementing ArangoQueryGenerator to write the AQL you wish to use. If you look at AbstractQueryGenerator as a guide, you will likely be able to achieve your desired result by removing the following lines in the filter() method, as that is the part of the query that allows for the flexibility I described above.

            sb.append(" OR (NOT ");
            sb.append(isSameCollection.toString());
            sb.append(")");

This would leave you with a limitation of only one traversal per level of your GraphQL schema - but that looks fine from your example above.

Hope that helps
CF

from arangodb-graphql-spring-boot-starter.

Related Issues (3)

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.