graphql-compose / graphql-compose/graphql-compose-mongoose

How to use with graphql-compose-relay

Open
#11 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
706
Forks
98
PR merge metrics
No merged PRs in 30d

Description

I want to use the generated types with graphql-compose-relay but I am not sure how:

```js
let UserTC = composeWithRelay(composeWithMongoose(User));

UserTC.addResolver({
name: 'testResolver',
kind: 'mutation',
...
args: {
arg1: 'String'
}
});

GQC.rootMutation.addFields({
'createOne': UserTC.getResolver('createOne'),
'testResolver': UserTC.getResolver('testResolver')
});
```

If I do the above, then `createOne` has `RelayCreateOneUserInput` type as the input argument, which I think is right for relay, but for `testResolver` it has `arg1: String` as the input argument, which I think is wrong.

I tried changing where composeWithRelay is called but it's still not right:

```js

let UserTC = composeWithMongoose(User);

UserTC.addResolver({
name: 'testResolver',
kind: 'mutation',
...
args: {
arg1: 'String'
}
});

UserTC = composeWithRelay(UserTC);

GQC.rootMutation.addFields({
'createOne': UserTC.getResolver('createOne'),
'testResolver': UserTC.getResolver('testResolver')
});
```

But the above is still not right because now `testResolver` has `RelayTestResolverInput` type, which I think is correct but now `createOne` has `RelayCreateOneUserInput` defined as:

```
record: CreateOneUserInput!
clientMutationId: String
```

So the input argument for `createOne` got wrapped twice I think?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.