vektah / gqlparser

A port of the parser from graphql-js into golang
MIT License
498 stars 123 forks source link

Can I parse the type of a field from query and schema? #253

Open zhaoyi0113 opened 1 year ago

zhaoyi0113 commented 1 year ago

I am looking for a parser to tell me what the type of a field clients want to resolve. For example, I have a schema like below code. When the server receive a query from clients, e.g. query getChat { getChat(id: \"0x01\") { id }}. Am I able to tell what the type of the response is.

I can see there are two methods ParseSchema and ParseQuery but I am not sure whether I can use these two methods to achieve what I need.

type Message {
  msg: String!
  id: ID!
  topic: String!
}

type Mutation {
  sendChat(topic: String!, message: String!): ID!
}

type Query {
  getChat(id: ID!): Message!
}

type Subscription {
  # Subscribe to events on the given topic.
  event(
    # Name of the topic to subscribe to.
    on: String!
  ): Message!
}