Questions

  • Must a GraphQL field be a Query type to be mentioned in a query?

    1 Say I have this GraphQL query: query GetUser($user_id: Int) { user(user_id: $user_id) { name } groups(user_id $user_id) { name } } This query recieves user id, and returns: user’s name names of all the groups this user belongs to I know that user should be defined in the SDL like this: type Query{ user(user_id: […]

  • Spring Boot Starter GraphQL LazyInitializationException

    0 I am currently implementing GraphQL into a system and am using Spring Boot 3.0.5 together with org.springframework.boot:spring-boot-starter-graphql to implement GraphQL schemas and queries. However there is a query that has issues. The relevant JPA entities: @Entity public class Video { @Id @Column(length = 24, nullable = false) private String videoId; @ManyToMany(mappedBy = "video") private […]

  • Why I got error: Cannot query field xx on type “Query”?

    57 Although I copied and pasted the graphQL query from the GraphiQL tool after I tested it at GraphiQL successfully , the query returned with an error when I tried it in Apollo client within a reactJS app: [GraphQL error]: Message: Cannot query field “allStudents” on type “Query”., Location: [object Object], Path: undefined Here is […]

  • How to make the ApolloClient useQuery method to await

    0 const claimableItemId = "5ab7c5ab-7a3d-4a92-a62f-2fbd995955f6"; const destAddr = "0x387961b46242A42B445D4354d5048329410613a7"; const [redeemEarnableItem, { data: redeemItem }] = useMutation( REDEEM_EARNABLE_ITEM, { variables: { claimableItemId, destAddr, }, } ); const [getInvoiceDetails, { loading, data: invoiceDetails, refetch }] = useQuery(GET_INVOICE_DETAILS); const redeemHandler = async () => { try { const redeemItem = await redeemEarnableItem(); const id = redeemItem.data.redeemEarnableItem.invoiceID; console.log(id, […]

  • GraphQL usage with REST Endpoints in .Net core 6.0

    0 Since I am new to GraphQL, I don’t really know how to call a REST Endpoint and query the fields accordingly. In particular, I want to fetch certain fields from the entire response of a GET API. What I have learnt is GraphQL sends a POST Request. How do I hit the GET endpoints […]

  • GraphQL only select items of certain type from array

    0 In my GraphQL API I have defined a course fragment with an array property lessons. Initially it only had lessons of type TextLesson. Later we added lessons of type VideoLesson as well. fragment TextLessonFields on TextLesson { title body } #fragment VideoLessonFields on VideoLesson { # title # videoUrl #} fragment CourseFields on Course […]

  • onCompleted of Apollo’s useLazyQuery does not get called when the execute function resolves

    0 I am facing a problem with the following snippet: const [execute] = useLazyQuery(gql` query Example($id: String!) { node(id: $id) { … on Train { id passengers(first: 1) { totalCount } } } } `) useEffect(() => { execute({ onCompleted: () => console.log("Hello world") }) }, []) interface Node { id: ID! } type PassengerConnection […]

  • How to use Apollo’s multiple useQuery() hooks in React

    2 I need to use 2 queries in my file and I am writing them like so: const {loading, data } = useQuery(getCharactersQuery); const {loading, data} = useQuery(getSingleCharacterQuery); The problem is, they both have the same "loading" and "data" variables and I don’t see anywhere in the docs how can we have different ones. How […]

  • Emulating signed integers using unsigned integers in C

    11 In Jens Gustedt’s book Modern C, on page 59, he explains how signed integers can be emulated using unsigned integers. His example code shows how one can implement a comparison of two unsigned integers reinterpreted as signed integers: bool is_negative(unsigned a) { unsigned const int_max = UINT_MAX /2; return a > int_max; } bool […]

  • GraphQL mutation issue with Enum

    0 I have object something like below: type SomeEventInput { event: Event } type Event { type: EventType! } enum EventType { MORNING EVENING AFTERNOON MIDNIGHT } Mutation.SomeEvent(input: SomeEventInput!): Boolean! What i am trying to test it something like : mutation SomeEvent($input: SomeEventInput!) { SomeEventInput(input: {Event: {type: MORNING}}) } But it is showing error for […]