简体   繁体   中英

What's the equivalent schema datatype for java.util.Set?

I am using GraphQL for Java and need to use Set / HashSet datatype for one of the member of my existing POJO to build by GraphQL schema. Any advice and insight is appreciated.

There is no built-in set type in GraphQL , sorry about that.

What you get the closest one is List type which is represented by enclosing any types using [ and ] such as [String] , [Int] , [Bar] etc. It can accept multiple elements but does not guarantee uniqueness between the containing elements.

You may consider to implement a directive for a set behaviour. May be called @set which is placed along with the list data type when defining your GraphQL schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM