Skip to content

Commit

Permalink
Fix: issue where all primary key queries were mandatory in default gr…
Browse files Browse the repository at this point in the history
…aphjin queries (#468)

* Updated the  basic documentation example

* Updated addTable function to create a new variable that would create the type that has not_null for id in the scenario where we query by ID

* Update intro.go

* Update intro.go

* Update intro.go

---------

Co-authored-by: Spacy <[email protected]>
  • Loading branch information
rkrishnasanka and dosco authored Dec 7, 2023
1 parent 347b070 commit 5d40427
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/intro.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,19 @@ func (in *Introspection) addTable(table sdata.DBTable, alias string) (err error)
}
in.addTypeTo("Mutation", ftM)

ftQS.addOrReplaceArg("id", newTypeRef(KIND_NONNULL, "", newTypeRef("", "ID", nil)))
in.addType(ftQS)
in.addTypeTo("Query", ftQS)
in.addTypeTo("Subscription", ftQS)
// add tableByID type to query and subscription
var ftQSByID FullType

if ftQSByID, err = in.addTableType(table, alias); err != nil {
return
}

ftQSByID.Name += "ByID"
ftQSByID.addOrReplaceArg("id", newTypeRef(KIND_NONNULL, "", newTypeRef("", "ID", nil)))
in.addType(ftQSByID)
in.addTypeTo("Query", ftQSByID)
in.addTypeTo("Subscription", ftQSByID)

return
}

Expand Down

1 comment on commit 5d40427

@vercel
Copy link

@vercel vercel bot commented on 5d40427 Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.