Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

graphQL populates don't support dot notation #274

Closed
mrfrase3 opened this issue May 20, 2019 · 0 comments
Closed

graphQL populates don't support dot notation #274

mrfrase3 opened this issue May 20, 2019 · 0 comments

Comments

@mrfrase3
Copy link

mrfrase3 commented May 20, 2019

Steps to reproduce

say we have the following line in our schema:

bookings: { type: '[Booking!]', args: true, relation: { ourTable: '_id', otherTable: 'billing.couponIds' } },

Expected behavior

The generated batch loader/service resolvers should detect a . in the name and wrap the field as a string:

    // Coupon.bookings(query: JSON, params: JSON, key: JSON): [Booking!]
    // !<DEFAULT> code: bl-Coupon-bookings
    case 'Coupon.bookings':
      return feathersBatchLoader(dataLoaderName, '[!]', 'billing.couponIds',
        keys => {
          feathersParams = convertArgs(args, content, null, {
            query: { 'billing.couponIds': { $in: keys }, $sort: undefined }, // <== stringify field
            _populate: 'skip', paginate: false
          });
          return bookings.find(feathersParams);
        },
        maxBatchSize // Max #keys in a BatchLoader func call.
      );
      // !end
      // bookings(query: JSON, params: JSON, key: JSON): [Booking!]
      bookings:
        // !<DEFAULT> code: resolver-Coupon-bookings
        (parent, args, content, ast) => {
          const feathersParams = convertArgs(args, content, ast, {
            query: { 'billing.couponIds': parent._id, $sort: undefined }, paginate: false // <== stringify field
          });
          return bookings.find(feathersParams).then(extractAllItems);
        },
        // !end

Actual behavior

No dot check, just adds in the literal string. This throws when the server start/eslint.

          feathersParams = convertArgs(args, content, null, {
            query: { billing.couponIds: { $in: keys }, $sort: undefined },
            _populate: 'skip', paginate: false
          });
          const feathersParams = convertArgs(args, content, ast, {
            query: { billing.couponIds: parent._id, $sort: undefined }, paginate: false
          });
@daffl daffl closed this as completed Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants