Cannot use 'in' operator to search for '#' in undefined
See original GitHub issueDescribe the bug After creating a new project with the loopback 4 cli, I try to create a graphql schema from the Openapi json file. However, it fails with following error:
openapi-to-graphql http://localhost:3000/openapi.json
OpenAPI-to-GraphQL creation event error: Cannot use 'in' operator to search for '#' in undefined
To Reproduce Steps to reproduce the behavior:
- Create new project with tslint (lb4 app)
- Create new model with id, name, image, subphase (lb4 controller)
- Create new in-memory datasource (lb4 datasource)
- Create new repository with DefaultCrudRepository (lb4 repository)
- Create new controller (lb4 controller)
- Start the project (npm start)
- Use openapi-to-graphql to get new schema (openapi-to-graphql http://localhost:3000/openapi.json)
- See above error
Expected behavior Expect a Graphql schema of this because I did not change any code of the model, repository or controller. It should at least work with a generated project to start developing.
Code
export class PartnerController {
constructor(
@repository(PartnerRepository)
public partnerRepository : PartnerRepository,
) {}
@post('/partners', {
responses: {
'200': {
description: 'Partner model instance',
content: {'application/json': {schema: getModelSchemaRef(Partner)}},
},
},
})
async create(
@requestBody({
content: {
'application/json': {
schema: getModelSchemaRef(Partner, {
title: 'NewPartner',
}),
},
},
})
partner: Partner,
): Promise<Partner> {
return this.partnerRepository.create(partner);
}
@get('/partners/count', {
responses: {
'200': {
description: 'Partner model count',
content: {'application/json': {schema: CountSchema}},
},
},
})
async count(
@param.where(Partner) where?: Where<Partner>,
): Promise<Count> {
return this.partnerRepository.count(where);
}
@get('/partners', {
responses: {
'200': {
description: 'Array of Partner model instances',
content: {
'application/json': {
schema: {
type: 'array',
items: getModelSchemaRef(Partner, {includeRelations: true}),
},
},
},
},
},
})
async find(
@param.filter(Partner) filter?: Filter<Partner>,
): Promise<Partner[]> {
return this.partnerRepository.find(filter);
}
@patch('/partners', {
responses: {
'200': {
description: 'Partner PATCH success count',
content: {'application/json': {schema: CountSchema}},
},
},
})
async updateAll(
@requestBody({
content: {
'application/json': {
schema: getModelSchemaRef(Partner, {partial: true}),
},
},
})
partner: Partner,
@param.where(Partner) where?: Where<Partner>,
): Promise<Count> {
return this.partnerRepository.updateAll(partner, where);
}
@get('/partners/{id}', {
responses: {
'200': {
description: 'Partner model instance',
content: {
'application/json': {
schema: getModelSchemaRef(Partner, {includeRelations: true}),
},
},
},
},
})
async findById(
@param.path.number('id') id: number,
@param.filter(Partner, {exclude: 'where'}) filter?: FilterExcludingWhere<Partner>
): Promise<Partner> {
return this.partnerRepository.findById(id, filter);
}
@patch('/partners/{id}', {
responses: {
'204': {
description: 'Partner PATCH success',
},
},
})
async updateById(
@param.path.number('id') id: number,
@requestBody({
content: {
'application/json': {
schema: getModelSchemaRef(Partner, {partial: true}),
},
},
})
partner: Partner,
): Promise<void> {
await this.partnerRepository.updateById(id, partner);
}
@put('/partners/{id}', {
responses: {
'204': {
description: 'Partner PUT success',
},
},
})
async replaceById(
@param.path.number('id') id: number,
@requestBody() partner: Partner,
): Promise<void> {
await this.partnerRepository.replaceById(id, partner);
}
@del('/partners/{id}', {
responses: {
'204': {
description: 'Partner DELETE success',
},
},
})
async deleteById(@param.path.number('id') id: number): Promise<void> {
await this.partnerRepository.deleteById(id);
}
}
If this issue is missing some information, please let me know!
Thanks, Maikel
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
TypeError: cannot use 'in' operator to search for 'x' in 'y'
The JavaScript exception "right-hand side of 'in' should be an object" occurs when the in operator was used to search in strings, ...
Read more >Cannot use 'in' operator to search for 'sth' in undefined
Problem was simply checking if object has xhr element. By default it does not exist so it's undefined , and you were asking...
Read more >JavaScript TypeError - Cannot use 'in' operator to search for 'X ...
Cause of the Error: The in operator can be used only for to check if a property is in an object. This can...
Read more >Error: Cannot use 'in' operator to search for 'undefined' in ...
I added all the variables myself in the Javascript. However, the problem now is TypeError: Cannot use 'in' operator to search for 'undefined' ......
Read more >Uncaught TypeError Cannot use in operator to search for 324
I'm trying to send a Get request by ajax and output json data that is returned by server in html. But, I got...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mcoenen1994 @yassinebenameur @Geril Sorry for the long wait. I couldn’t find any time at all to work on OtG in the last for weeks. I believe I have finally resolved this issue however. Please update to
v2.1.1
and let me know if this problem still persists.@mcoenen1994 Your repo was instrumental to debugging this problem. Thank you very much for creating it!
Works for me as well! Thanks!