Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 16 17:11
    dependabot[bot] labeled #386
  • May 16 17:11
    dependabot[bot] opened #386
  • May 16 17:11

    dependabot[bot] on npm_and_yarn

    build(deps): bump node-fetch fr… (compare)

  • May 16 11:02
    Resousse opened #385
  • May 10 13:42
    Resousse edited #384
  • May 10 13:26
    Resousse edited #384
  • May 10 13:24
    Resousse edited #384
  • May 10 13:23
    Resousse opened #384
  • May 03 13:57
    disintegrator edited #383
  • May 03 13:10
    adambaratz commented #374
  • May 03 11:07
    disintegrator commented #374
  • May 03 09:49
    disintegrator opened #383
  • Apr 28 19:55
    brianlenz commented #382
  • Apr 28 19:31
    brianlenz commented #382
  • Apr 28 18:24
    brianlenz commented #382
  • Apr 28 18:09
    brianlenz edited #382
  • Apr 28 18:06
    brianlenz commented #382
  • Apr 28 18:01
    brianlenz commented #382
  • Apr 28 17:43
    brianlenz edited #382
  • Apr 28 17:43
    brianlenz opened #382
Kristoffer
@stoffern
@andrewhickey you have projection..
Andrew Hickey
@andrewhickey
you're looking for an example query?
Andrew Hickey
@andrewhickey
oh right, I've not explicitly added any. I thought that the lib added them based on the fields you select in your GQL query
Kristoffer
@stoffern
oh, my bad..
i did not know what projection was :D
Kristoffer
@stoffern
@andrewhickey he says that my example it legit..
solution to your problem
Andrew Hickey
@andrewhickey

Hmm, that still has the problems we saw above with toDottedObject although, in the example, you have

resolveParams.args = {
        $and: [
          { "a": 1 }
          { "$or":  [
             "b": 2,
             "c": 2 
          ]}
        ]
      }

and i think that would have to be

resolveParams.args.filter = {
        $and: [
          { "a": 1 }
          { "$or":  [
             "b": 2,
             "c": 2 
          ]}
        ]
      }

using the example of real data sending in a query such as

{
  '$and': [
    {
      '$comment': '{"criterionLabel":"A","criteriaPath":["statement","actor"]}',
      '$or': [
        {
          'statement.actor.account.homePage': 'http://beta.curatr3.com',
          'statement.actor.account.name': 'e9fb7843-6958-432e-829e-09a3255d897c'
        },
        {
          'statement.actor.account.homePage': 'http://beta.curatr3.com',
          'statement.actor.account.name': '91091d5d-551d-479c-a349-b1fb3b87bb09'
        }
      ]
    }
  ]
}

I get an output query of

{
  '$and.$and.0.$comment': '{"criterionLabel":"A","criteriaPath":["statement","actor"]}',
  '$and.$and.0.$or.0.statement.actor.account.homePage': 'http://beta.curatr3.com',
  '$and.$and.0.$or.0.statement.actor.account.name': 'e9fb7843-6958-432e-829e-09a3255d897c',
  '$and.$and.0.$or.1.statement.actor.account.homePage': 'http://beta.curatr3.com',
  '$and.$and.0.$or.1.statement.actor.account.name': '91091d5d-551d-479c-a349-b1fb3b87bb09'
}
Kristoffer
@stoffern
@andrewhickey sorry to hear that.. it is clearly a issue with the dots function. I think you should make a issue on this, with those logs.. @nodkz is back from vacation soon i guess
i think complexe queries should be suppored in some way :smile:
Andrew Hickey
@andrewhickey
No rush, I saw he had some opinions on how this should be handled
I'm happy to submit a PR with a possible implementation
Kristoffer
@stoffern
:thumbsup:
i am starting to get a hang of this code now.. it is a little complex..
Kristoffer
@stoffern
@andrewhickey you should be able to access operators throu: filter._operators ....
Pavel Chertorogov
@nodkz
@andrewhickey sorry I was on vacation.
That's what you were looking for nodkz/graphql-compose#22
Kristoffer
@stoffern
@andrewhickey what about this:
User.find({
  '$or':[ 
    {firstname:new RegExp(searchText,'i')},
    {lastname:new RegExp(searchText,'i')},
    {email:new RegExp(searchText,'i')}
  ]});
})
pszabop
@pszabop
last message Oct 24. anyone monitoring this?
Pavel Chertorogov
@nodkz
@pszabop Sorry but I'm very rarely visit this chat. Too busy under my internal project.
Cameron Ellis
@cellis
Hello @nodkz. I'm still interested in building the knex plugin. I'm also trying to learn how to use the API to get a better understanding ( so I can write the knex plugin! ). I've noticed in https://github.com/nodkz/graphql-compose/tree/master/docs/04-api-reference that there are examples like:
GQC.rootQuery().addFields({
  city: CityTC.get('$findOne'),
  cityConnection: CityTC.get('$connection'),
  currentTime: {
    type: 'Date',
    resolve: () => Date.now(),
  },
  // ...
});

GQC.rootMutation().addFields({
  createCity: CityTC.get('$createOne'),
  updateCity: CityTC.get('$updateById'),
  // ...
});
But how are those get calls resolved? Where is e.g. $createOne defined? Is this a mongoose method?
Cameron Ellis
@cellis
Never mind, I figured this out
Alain Armand
@idkjs
test
is this room still active?
Last message i see in Jan 22.
Kristoffer
@stoffern
@idkjs well i would say it is becomming active... the repo is quite new and plugins are beeing worked on :wink: Can i help you?
@cellis just feel free to ask, i will be more online from now and forward :wink:
Evgeni Korsunov
@sensone

Hi, everyone
I need a help.

So, I have a Shema

const UserSchema = new Schema({
  name: String,
  gender: { 
    type: String,
    enum: ['male', 'female', 'ladyboy'],
  },
  city: String
},
{
  collection: 'users'
});
const User = mongoose.model('User', UserSchema);
const UserTC = composeWithRelay(composeWithMongoose(User));
...

I have add new field

UserTC.addFields({
  foo: {
    type: GraphQLString,
    projection: { test: true, gender: true },
    resolve: (source) => (`${source.test} ${source.gender}`)
  },
})

And I would like add another field depended from foo field

UserTC.addFields({
  bar: {
    type: GraphQLString,
    projection: { foo: true },
    resolve: (source) => (`${source.foo} is awesome`) // but source.foo is undefined
  },
})

But source.foo is undefined. What should I do for fix it ?
Thanks

Evgeni Korsunov
@sensone
I understand that projection depends only from Shema fields, but how i can implement this functionality ?
Kristoffer
@stoffern
try:
UserTC.addFields({
  foo: {
    type: GraphQLString,
    projection: { test: true, gender: true },
    resolve: (source) => (`${source.test} ${source.gender}`)
  },
  bar: {
    type: GraphQLString,
    projection: { foo: true },
    resolve: (source) => (`${source.foo} is awesome`) // but source.foo is undefined
  },
})
Evgeni Korsunov
@sensone
@stoffern, thank you. I tried... It didn't help
Kristoffer
@stoffern
@sensone why not create a function that resolves foo, then use the same function inside bar?
Evgeni Korsunov
@sensone
@stoffern, Thank you. I did as you say, but for me was interesting Can I use custom fields for creating another fields
Kristoffer
@stoffern
@sensone i can see that would be a profit. Please create a issue on it so it can be looked at :wink:
Evgeni Korsunov
@sensone
@stoffern, Ok, I'll do it evening :)
Evgeni Korsunov
@sensone
done ))
omarkhaled11
@omarkhaled11
Hello :)
is there a way to get the validation messages from mongoose to be displayed in the return result of the graphql query?
instead of the 'User Validation Error' message?
Kristoffer
@stoffern
@omarkhaled11 create a issue on it. We are all on vacation at the moment so please be a little patient for a answer :wink:
omarkhaled11
@omarkhaled11
sure :) have fun guys!
Angel J Piscola
@Redmega
Hi guys, I have a productConnection within a category model, which is used to fetch the products belonging to that category. I am trying to add a filter in order ot filter by type, color, etc.. Having trouble figuring how out to do that. I have created a filter arg on the productConnection modeling the regexp one, which works if the query is viewer { productConnection(filter: blah) { etc } }, but I am unable to put it on my embedded connection like so:
query {
  viewer {
    category {
      ...
      productConnection(filter: { nameRegex: 'blah' }) {
      }
    }
  }
}
I just get "unknown argument filter. did you mean after?"
Angel J Piscola
@Redmega
Btw happy vacation :)
Angel J Piscola
@Redmega
Update: Seems like if I hardcode nameregex in the productConnection relation, it works:
CategoryTC.addRelation(
  'productConnection',
  () => ({
    resolver: ProductTC.getResolver('connection'),
    args: {
      filter: (source) => ({
        _operators: { // eslint-disable-line no-underscore-dangle
          _id: { in: source.products }, // eslint-disable-line no-underscore-dangle
        },
        nameRegex: 'plat',
      }),
      sort: { sortOrder: 1 },
    },
    projection: { products: true },
  }),
);
How can I then get the nameRegex val from the query on my jsx? I've seen examples where the entire filter is in the query but I would rather keep the _id operator in the relation itself.