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
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.
Angel J Piscola
@Redmega
The issue I'm facing is I have the product connection related to Category as previously shared. On the product query I am not allowed to put a filter on the productConnection part of the query, because I have the filter in the productConnection filtering by _id. When I remove this filter I can place filter() on the productConnection part of the Category query, but then I lose the ability to filter by id
const extendedResolver = ProductTC
  .getResolver('connection')
  .addFilterArg({
    name: 'nameRegex',
    type: 'String',
    description: 'Filter by product id',
    query: (query, value, resolveParams) => { // eslint-disable-line
      query.name = new RegExp(value, 'i');
    },
  });
extendedResolver.name = 'connection';
ProductTC.addResolver(extendedResolver);
Angel J Piscola
@Redmega
I think I'll just move the _operators with _id to the query itself so I can use filter() in the query instead of only in the relationship
Angel J Piscola
@Redmega
Hey guys, faced another blocker trying to implement a custom input type. Maybe I'm doing it wrong?
I've got my custom type and extended resolver like so:
const SelectedAttributeType = InputTypeComposer.create(new GraphQLObjectType({
  name: 'SelectedAttribute',
  fields: () => ({
    group: { type: GraphQLString },
    values: { type: GraphQLList(GraphQLString) },
  }),
}));

const extendedResolver = ProductTC
  .getResolver('connection')
  .addFilterArg({
    name: 'attributeFilter',
    type: new GraphQLList(SelectedAttributeType.getType()),
    description: 'Filter by attribute groups',
    query: (query, value, resolveParams) => { // eslint-disable-line
      query.name = new RegExp(value, 'i');
    },
  });
extendedResolver.name = 'connection';
ProductTC.addResolver(extendedResolver);
This does not build, however, giving me: Error: SelectedAttribute fields must be an object with field names as keys or a function which returns such an object.
Removing the function and making it an object breaks it further, giving me the TypeError: Cannot call a class as a function error.
Anthony Ou
@Anthonyzou
the graphql 0.10.0 update seems to break things
also you should consider a donate button. This is really cool!
NiklasN
@Strutsagget
Hello, where should i start reading in docs about prepopulating query fields from auth user
if i got req.user populated from express-jwt.
Nick Parsons
@nparsons08
Hey there, new to the project and looking for some help provided the lack of documentation. I'm migrating from a RESTful API with several endpoints. Anyone available to point me in the right direction for docs? Right now I believe I have everything setup correctly, however, I cannot seem to get the darn GraphiQL UI to show me the Root Types.