Collection types​

This section describes introspection of collection types.

Array​

Introspection of the schema::Array:

  1. with module schema
  2. select ObjectType {
  3. name,
  4. links: {
  5. name,
  6. },
  7. properties: {
  8. name,
  9. }
  10. }
  11. filter .name = 'schema::Array';
  1. {
  2. Object {
  3. name: 'schema::Array',
  4. links: {
  5. Object { name: '__type__' },
  6. Object { name: 'element_type' }
  7. },
  8. properties: {
  9. Object { name: 'id' },
  10. Object { name: 'name' }
  11. }
  12. }
  13. }

For a type with an array property, consider the following:

  1. type User {
  2. required property name -> str;
  3. property favorites -> array<str>;
  4. }

Introspection of the User with emphasis on properties:

  1. with module schema
  2. select ObjectType {
  3. name,
  4. properties: {
  5. name,
  6. target: {
  7. name,
  8. [is Array].element_type: { name },
  9. },
  10. },
  11. }
  12. filter .name = 'default::User';
  1. {
  2. Object {
  3. name: 'default::User',
  4. properties: {
  5. Object {
  6. name: 'favorites',
  7. target: Object {
  8. name: 'array',
  9. element_type: Object { name: 'std::str' }
  10. }
  11. },
  12. ...
  13. }
  14. }
  15. }

Tuple​

Introspection of the schema::Tuple:

  1. with module schema
  2. select ObjectType {
  3. name,
  4. links: {
  5. name,
  6. },
  7. properties: {
  8. name,
  9. }
  10. }
  11. filter .name = 'schema::Tuple';
  1. {
  2. Object {
  3. name: 'schema::Tuple',
  4. links: {
  5. Object { name: '__type__' },
  6. Object { name: 'element_types' }
  7. },
  8. properties: {
  9. Object { name: 'id' },
  10. Object { name: 'name' }
  11. }
  12. }
  13. }

For example, below is an introspection of the return type of the sys::get_version() function:

  1. with module schema
  2. select `Function` {
  3. return_type[is Tuple]: {
  4. element_types: {
  5. name,
  6. type: { name }
  7. } order by .num
  8. }
  9. }
  10. filter .name = 'sys::get_version';
  1. {
  2. Object {
  3. return_type: Object {
  4. element_types: {
  5. Object {
  6. name: 'major',
  7. type: Object {
  8. name: 'std::int64'
  9. }
  10. },
  11. Object {
  12. name: 'minor',
  13. type: Object {
  14. name: 'std::int64'
  15. }
  16. },
  17. Object {
  18. name: 'stage',
  19. type: Object {
  20. name: 'sys::VersionStage'
  21. }
  22. },
  23. Object {
  24. name: 'stage_no',
  25. type: Object {
  26. name: 'std::int64'
  27. }
  28. },
  29. Object {
  30. name: 'local',
  31. type: Object { name: 'array' }
  32. }
  33. }
  34. }
  35. }
  36. }