Skip to content

How to make a simple nested encapsulation? #3013

Answered by Everettss
Everettss asked this question in Q&A
Discussion options

You must be logged in to vote

The key to answer is to add an resolver for nestedType like in file ./additional-resolvers.js

const resolvers = {
  Query: {
    nestedType: () => ({})
  },
};

module.exports = { resolvers };

Next add additional resolvers for those fields in .meshrc.yaml

additionalTypeDefs: |
  type NestedType {
      healthcare: healthcareQuery
      wikimedia: wikimediaQuery
  }

  extend type Query {
      nestedType: NestedType
  }
additionalResolvers:
  - targetTypeName: NestedType
    targetFieldName: wikimedia
    sourceName: Wikimedia
    sourceTypeName: Query 
    sourceFieldName: wikimedia
  - targetTypeName: NestedType
    targetFieldName: healthcare
    sourceName: Healthcare 
    sourceTypeName

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Everettss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant