-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seeing undefined arg data when using imports
making some resolvers useless
#1243
Comments
I've changed direction and also found it might be an issue with Apollo too. Closing. Scott |
Actually, I'm reopening, as GraphQL-Modules seems to be broken with Type-GraphQL and I'd like to see the two working together. Thanks. Scott |
Hey @smolinari you have a working implementation by typegraphql author. and another example by ardatan from the guild (gql-modules contributor) https://github.com/ardatan/TypeGraphQLModules Example of my document model/entity/type import {
Field,
ID,
ObjectType,
} from 'type-graphql';
import {
BaseEntity,
Column,
CreateDateColumn,
Entity,
PrimaryGeneratedColumn,
UpdateDateColumn,
VersionColumn,
} from 'typeorm';
/**
* @export
* @class Document
* @extends {BaseEntity}
*/
@Entity()
@ObjectType()
export default class Document extends BaseEntity {
@Field(() => String)
@PrimaryGeneratedColumn('uuid')
id: string;
@Field(() => String)
@Column()
title: string;
@Field(() => Boolean)
@Column({ default: false })
isPublished: boolean;
@Field(() => ID)
@Column()
authorId: string;
@Field()
@Column()
content: string;
} |
Yeah, that template used to work. It doesn't since TypeGraphQL went 1.0. See this issue too. And I see you commented in that issue too, so you are aware of the incompatibility. Scott |
Checkout the other one which is updated for type-graphql 1.0.0rc3 https://github.com/MichalLytek/type-graphql/tree/master/examples/graphql-modules I can confirm I have typegraphql v1 and graphql-modules "^0.7.18-alpha-6c93635.67", working together |
And I can confirm that it doesn't work ( I upgraded to the same version you are using). My use case might be different than yours, so 🤷 Btw, are you using Apollo Server with Express? Or just graphql-express? That might be the key difference too. Scott |
Yes I'm using Apollo-Server-Express Your resolvers and mine are very different though |
They are just using resolver inheritance also taken from the TypeGraphQL examples. What do your resolvers look like? Can you show an example or link to your code? Scott |
import {
Arg,
Mutation,
Query,
Resolver,
} from 'type-graphql';
import { Injectable } from '@graphql-modules/di';
import { CreateDocumentInput } from '../inputs/create.document.input';
import { UpdateDocumentInput } from '../inputs/update.document.input';
import Document from '../models/document.model';
import DocumentProvider from '../providers/document.provider';
/**
*
*
* @export
* @class DocumentResolver
*/
@Injectable()
@Resolver((of) => Document)
export default class DocumentResolver {
constructor(private readonly documentProvider: DocumentProvider) {}
/**
*
*
* @returns
* @memberof DocumentResolver
*/
@Query(() => [Document])
documents() {
return this.documentProvider.getAll();
}
/**
*
*
* @param {string} id
* @returns
* @memberof DocumentResolver
*/
@Query(() => Document)
document(@Arg("id") id: string) {
return this.documentProvider.findDocumentById(id);
}
/**
*
*
* @param {CreateDocumentInput} data
* @returns
* @memberof DocumentResolver
*/
@Mutation(() => Document)
createDocument(@Arg("data") data: CreateDocumentInput) {
return this.documentProvider.create(data);
}
/**
*
*
* @param {string} id
* @param {UpdateDocumentInput} data
* @returns
* @memberof DocumentResolver
*/
@Mutation(() => Document)
async updateDocument(
@Arg("id") id: string,
@Arg("data") data: UpdateDocumentInput
) {
return this.documentProvider.update(data, id)
}
/**
*
*
* @param {string} id
* @returns
* @memberof DocumentResolver
*/
@Mutation(() => Boolean)
async deleteDocument(@Arg("id") id: string) {
return this.documentProvider.delete(id)
}
} |
Thanks for that. Is Scott |
Closing once more. My new direction seems to be working now, so this isn't an issue for me anymore. Scott |
Hi,
As noted in Discord, I think I've possibly found a bug, or my usage of both TypeGraphQL and GraphQL-Modules isn't as it should be. Either way, I'd like someone with much more experience to have a look.
Here is the reproduction: https://github.com/smolinari/gql-modules-test
Follow the readme.md of that repo to get the server running.
Then run this query:
You can see the error:
Cannot return null for non-nullable field Query.getOneRecipe.
( I realize this should be nullable field, however, if I add the null check, then it will just return null, when it should return the recipe.) This error happens because the argumentid
is undefined getting to the resolver. You'll see, inBaseResolver
, I'm console.logging out theid
argument and it shows in the terminal asundefined
.If you go to
index.ts
and comment out theUserModule
within theimports
property of theGraphQLModule
config parameter, then the query will work, which I believe proves the collision happening with importing.Scott
The text was updated successfully, but these errors were encountered: