Designer 10.7 | webMethods Service Development Help | Working with GraphQL Descriptors | Creating a GraphQL Descriptor | How Integration Server Invokes a Resolver Service While Processing a GraphQL Request
 
How Integration Server Invokes a Resolver Service While Processing a GraphQL Request
For example, consider the following sample schema,
Schema:
type Query {
getLink: Link
}

type Link {
id: ID
url: String
postedBy(id: ID): User
}

type User {
id: ID
name: String
address: Address
}

type Address {
line1: String
line2: String
}
When you import the above schema with name graphqlSample, Integration Server generates all the document types and resolvers as:
To query the getLink field, you can send a request using GET or POST method. If you send the request using POST method and the content type is application/graphql, the URL for the request is:
http://<HOST>:<port>/graphql/tests/graphqlSample
The content in the request body is:
{
getLink {
id
url
postedBy (id:1){
id
name
address {
line1
line2
}
}
}
}
Here, Integration Server queries all the fields from Link, User, and Address types.
Once the request reaches Integration Server, it processes the request as:
1. Invokes the root resolver tests.graphqlSample_.resolvers.Query:getLinkResolver to resolve getLink field. This service sets the values for fields id and url. The postedBy field is of type Object so Integration Server invokes child resolver to resolve postedBy.
2. Invokes the child resolver tests.graphqlSample_.resolvers.Link:postedByResolver to resolve postedBy field. Integration Server populates the data returned from the parent resolver (getLinkResolver) for the field getLink under parent field as the input of this service. Integration Server populates the value of input argument id=1 under args field. This resolver sets the value for fields id and name. The address field is of type Object, so Integration Server invokes the child resolver to resolve address.
3. Invoke the child resolver tests.graphqlSample_.resolvers.User:addressResolver to resolve address field. Integration Server populates the data returned from the parent resolver (postedByResolver) for the field postedBy under parent field as input. There is no argument for this field so Integration Server does not populate anything in args field. This resolver service sets the value for fields line1 and line2.
4. Integration Server collects the data and returns the requested data in response.