Skip to content

Commit

Permalink
fix: error when only ask for __typename
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Simon committed Jul 25, 2023
1 parent 8fa927f commit e7acd7f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 6 deletions.
5 changes: 4 additions & 1 deletion generate_code_resolver.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
}
var res []*model.{{$object.Name}}
tableName := r.Sql.Db.Config.NamingStrategy.TableName("{{$object.Name}}")
db = runtimehelper.GetPreloadSelection(ctx, db,runtimehelper.GetPreloadsMap(ctx, "data").SubTables[0])
preloadSubTables := runtimehelper.GetPreloadsMap(ctx, "data").SubTables
if len(preloadSubTables)> 0{
db = runtimehelper.GetPreloadSelection(ctx, db,runtimehelper.GetPreloadsMap(ctx, "data").SubTables[0])
}
if filter != nil{
blackList := make(map[string]struct{})
sql, arguments := runtimehelper.CombineSimpleQuery(filter.ExtendsDatabaseQuery(db, fmt.Sprintf("%[1]s%[2]s%[1]s",runtimehelper.GetQuoteChar(db), tableName), false, blackList), "AND")
Expand Down
8 changes: 8 additions & 0 deletions integration/__snapshots__/generated_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10033,3 +10033,11 @@ gqlerror.List{
},
}
---

[TestQueryTestSuite/TestComplexCombination/no_data_query - 1]
&integration.noDataQueryResponse{
QueryUser: &integration.noDataQueryQueryUserUserQueryResult{
Typename: &"UserQueryResult",
},
}
---
44 changes: 44 additions & 0 deletions integration/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions integration/generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ func (suite *QueryTestSuite) TestComplexCombination() {
return getAllTodosWithUserGroupById(context.Background(), suite.Client)
}))

suite.T().Run("no data query", queryTester(func() (any, error) {
return noDataQuery(context.Background(), suite.Client)
}))

suite.T().Run("allTodosPartOfCompany => TestCompany2", queryTester(func() (any, error) {
companyName := "TestCompany2"
return allTodosPartOfCompany(context.Background(), suite.Client, &companyName)
Expand Down
7 changes: 7 additions & 0 deletions integration/genqlient.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ query allUserWithACatOnlyUserId{
}
}

query noDataQuery{
queryUser(filter:{cat:{userID: {notNull:true}}}){
__typename
}
}

query allTodosPartOfCompany($companyName:String){
queryTodo(filter: { users:{company: {name: {eq: $companyName}}}}, order:{desc:id}){
data{
Expand Down Expand Up @@ -297,6 +303,7 @@ query getAllTodosWithUserGroupById{
}
}


query getUserById($userId:ID!){
getUser(id:$userId){
id
Expand Down
25 changes: 20 additions & 5 deletions testservice/graph/autogql.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e7acd7f

Please sign in to comment.