Graphback: Ability to query relationship is for One type only

Created on 9 Aug 2019  路  12Comments  路  Source: aerogear/graphback

Background

Currently given a relation

type User {
    comments: [Comment]
}

We are only generating comments field for the User type. We should also generate resolver for the 2nd type such that a query like this would be possible

query {
    findAllComments {
        user {
            name
        }
    }
}
enhancement

Most helpful comment

If someone is not already working on this and if I had time to start looking at it where would you suggest I start looking?

If I made changes how would I run the updated graphback to see if my changes worked?

All 12 comments

So if we do

type User {
    ....
    comments: [Comment]
}

we are generating these in the schema

type User {
    ....
    comments: [Comment]
}

and

type Comment {
    ....
    userId: ID!
}

If we do

type Comment {
    ....
    user: User!
}

instead, this will allow to do the query and implement the resolver accordingly.

Good catch! We do not need any extra generation flag or directive for this as it will be expected to have this capability all the time.

@richcorbs thank you for logging this issue

If someone is not already working on this and if I had time to start looking at it where would you suggest I start looking?

If I made changes how would I run the updated graphback to see if my changes worked?

Is this close to the right place and the right thing?

Screen Shot 2019-08-10 at 2 05 23 PM

If someone is not already working on this and if I had time to start looking at it where would you suggest I start looking?

Yes sure, go ahead.

Is this close to the right place and the right thing?

Yes this is it.

If I made changes how would I run the updated graphback to see if my changes worked?

There's a command in project root bootstrap, do npm run bootstrap after running npm run build(after making the changes). Lastly do npm link in graphback-cli to install the development version of the package.

If you hit any problems with contribution let us know. We can add more info to Contributing.md.
If code changes were made feel free to create PR, our team will help with verification and merge.

PR #225 submitted.

There's a command in project root bootstrap, do npm run bootstrap after running npm run build(after making the changes). Lastly do npm link in graphback-cli to install the development version of the package.

npm run bootstrap stopped working for me locally. I don't think I changed anything. The errors are odd to me. I've run npm install. I deleted and reinstalled node_modules. Any ideas?

$ npm run build

> [email protected] build /Users/rich/Source/graphback
> lerna run build

lerna notice cli v3.16.4
lerna info Executing command in 5 packages: "npm run build"
lerna ERR! npm run build exited 2 in 'graphql-js-template'
lerna ERR! npm run build stdout:

> [email protected] build /Users/rich/Source/graphback/templates/graphql-js-starter
> tsc

node_modules/graphql-redis-subscriptions/dist/redis-pubsub.d.ts(2,30): error TS2307: Cannot find module 'graphql-subscriptions'.
src/context.ts(1,21): error TS7016: Could not find a declaration file for module 'express'. '/Users/rich/Source/graphback/templates/graphql-js-starter/node_modules/express/index.js' implicitly has an 'any' type.
  Try `npm install @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`
src/index.ts(1,18): error TS7016: Could not find a declaration file for module 'cors'. '/Users/rich/Source/graphback/templates/graphql-js-starter/node_modules/cors/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/cors` if it exists or add a new declaration (.d.ts) file containing `declare module 'cors';`
src/index.ts(2,21): error TS7016: Could not find a declaration file for module 'express'. '/Users/rich/Source/graphback/templates/graphql-js-starter/node_modules/express/index.js' implicitly has an 'any' type.
  Try `npm install @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`

lerna ERR! npm run build stderr:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rich/.npm/_logs/2019-08-16T22_28_27_054Z-debug.log

lerna ERR! npm run build exited 2 in 'graphql-js-template'
lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `lerna run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I think this is a bug in js-template.
We going to fix it tommorow.
For now you can avoid building js template by renaming package.json to anything else.

It is strange that CI did not detected that.
I will check it once I get access to laptop

Thanks.

How can we communicate outside of github issues? Is there a gitter or discord for the project?

Was this page helpful?
0 / 5 - 0 ratings