Giter Site home page Giter Site logo

markshapiro / graphql-db-projection Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 0.0 104 KB

Create projection of fields needed to fetch from db from Graphql query. Supports nested queries & custom field names.

License: MIT License

JavaScript 100.00%
apollo apollo-server graphql graphql-projection mongodb projection

graphql-db-projection's Issues

Get first level of projection only

Hello!

first thank you for you work, it saves me a lot of time for my project!
I was wondering, how to parse ASTFields with your lib to get only first level fields (and transform multi level in first level). To be clear this is an example :

this is a request I made in GraphiQL

{
  My_item(id: "abcdefghijklmnoqlsnejngwd") {
    id
    name
    function {
      subfield1
      subfield2
    }
  }
}

by default I get this with your functions (makeProjection and toMongoProjection):
id: 1, name: 1, 'function.subfield1': 1, 'function.subfield2': 1

I would like to have something similar to this:
id: 1, name: 1, 'function: 1

I saw in your documentation that we can do that:

@proj(projections: [])

in our GraphQL schema, so I tried to make it work but this time I don't get my object at all so I can't make any request with its id as you suggest it here :

// but not posts as we explicitly omitted them because they are located in different collection

May be I didn't get something or did something wrong, IDK for the moment.

The only workaround I've found is to do something like:

function:            Function @proj(projection: "function")

in my Schema. It not seems to be a clean way to do it..
Do you have any ideas? thanks!

Projection of "InlineFragment"

Thanks for a great project.

My objective is to generate projection for Graphql Queries, containing InlineFragments.

Do you have any suggestions how to support this?

How to handle inline fragment?

Hello,

Do you have any ideas to handle inline fragments with your library in order to generate projections?

Thanks

Alvyre

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.