Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql, astToQuery and subarrays #379

Open
promentol opened this issue Sep 14, 2019 · 1 comment
Open

Graphql, astToQuery and subarrays #379

promentol opened this issue Sep 14, 2019 · 1 comment

Comments

@promentol
Copy link

Here is my typeDefs and resolvers

    type Query {
      professionals(companyId: String!): [Professional]
      company(route: String!): Company
    }

    type Company {
      name: String!
      route: String
      professionals: [Professional]
    }

    type Professional {
      name: String!
      avatar: String
      company: Company
      services: [Service]
    }

    type Service {
      _id: String
      name: String
      price: String
      duration: Int
      categoryId: String!
    }
company(_, args, { db }, ast) {
        
        return db.companies.astToQuery(ast, {
          $filters: {
            route: args.route
          }
        }).fetchOne()
      },
professionals(_, args, { db }, ast) {
        return db.professionals.astToQuery(ast, {
          $filters: {
            companyId: args.companyId
          }
        }).fetch();
      },

The problem is when querying companies, the services have the following result

{
   name: [..],
   price: [..]   
}

Here is my query. Queries professionals works normally

query {
  company(route: "_") {
    name,
    professionals {
      name,
      services {
      	_id,
        name,
        price
      }
    }
  }
}
@theodorDiaconu
Copy link
Contributor

How did you link company and professionals inside grapher ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants