@@ -1380,6 +1380,317 @@ func TestExecutionPlan_FederationRequires(t *testing.T) {
13801380 },
13811381 },
13821382 },
1383+ {
1384+ name : "requires with direct enum field" ,
1385+ query : `query EntityLookup($representations: [_Any!]!) { _entities(representations: $representations) { ... on Storage { __typename name kindSummary } } }` ,
1386+ mapping : testMapping (),
1387+ federationConfigs : plan.FederationFieldConfigurations {
1388+ {
1389+ TypeName : "Storage" ,
1390+ SelectionSet : "id" ,
1391+ },
1392+ {
1393+ TypeName : "Storage" ,
1394+ FieldName : "kindSummary" ,
1395+ SelectionSet : "storageKind" ,
1396+ },
1397+ },
1398+ expectedPlan : & RPCExecutionPlan {
1399+ Calls : []RPCCall {
1400+ {
1401+ ServiceName : "Products" ,
1402+ MethodName : "LookupStorageById" ,
1403+ Kind : CallKindEntity ,
1404+ Request : RPCMessage {
1405+ Name : "LookupStorageByIdRequest" ,
1406+ Fields : []RPCField {
1407+ {
1408+ Name : "keys" ,
1409+ ProtoTypeName : DataTypeMessage ,
1410+ Repeated : true ,
1411+ JSONPath : "representations" ,
1412+ Message : & RPCMessage {
1413+ Name : "LookupStorageByIdRequestKey" ,
1414+ MemberTypes : []string {"Storage" },
1415+ Fields : []RPCField {
1416+ {
1417+ Name : "id" ,
1418+ ProtoTypeName : DataTypeString ,
1419+ JSONPath : "id" ,
1420+ },
1421+ },
1422+ },
1423+ },
1424+ },
1425+ },
1426+ Response : RPCMessage {
1427+ Name : "LookupStorageByIdResponse" ,
1428+ Fields : []RPCField {
1429+ {
1430+ Name : "result" ,
1431+ ProtoTypeName : DataTypeMessage ,
1432+ Repeated : true ,
1433+ JSONPath : "_entities" ,
1434+ Message : & RPCMessage {
1435+ Name : "Storage" ,
1436+ Fields : []RPCField {
1437+ {
1438+ Name : "__typename" ,
1439+ ProtoTypeName : DataTypeString ,
1440+ JSONPath : "__typename" ,
1441+ StaticValue : "Storage" ,
1442+ },
1443+ {
1444+ Name : "name" ,
1445+ ProtoTypeName : DataTypeString ,
1446+ JSONPath : "name" ,
1447+ },
1448+ },
1449+ },
1450+ },
1451+ },
1452+ },
1453+ },
1454+ {
1455+ ID : 1 ,
1456+ ServiceName : "Products" ,
1457+ Kind : CallKindRequired ,
1458+ MethodName : "RequireStorageKindSummaryById" ,
1459+ ResponsePath : buildPath ("_entities.kindSummary" ),
1460+ Request : RPCMessage {
1461+ Name : "RequireStorageKindSummaryByIdRequest" ,
1462+ Fields : []RPCField {
1463+ {
1464+ Name : "context" ,
1465+ ProtoTypeName : DataTypeMessage ,
1466+ Repeated : true ,
1467+ JSONPath : "representations" ,
1468+ Message : & RPCMessage {
1469+ Name : "RequireStorageKindSummaryByIdContext" ,
1470+ Fields : []RPCField {
1471+ {
1472+ Name : "key" ,
1473+ ProtoTypeName : DataTypeMessage ,
1474+ Message : & RPCMessage {
1475+ Name : "LookupStorageByIdRequestKey" ,
1476+ MemberTypes : []string {"Storage" },
1477+ Fields : []RPCField {
1478+ {
1479+ Name : "id" ,
1480+ ProtoTypeName : DataTypeString ,
1481+ JSONPath : "id" ,
1482+ },
1483+ },
1484+ },
1485+ },
1486+ {
1487+ Name : "fields" ,
1488+ ProtoTypeName : DataTypeMessage ,
1489+ Message : & RPCMessage {
1490+ Name : "RequireStorageKindSummaryByIdFields" ,
1491+ Fields : []RPCField {
1492+ {
1493+ Name : "storage_kind" ,
1494+ ProtoTypeName : DataTypeEnum ,
1495+ JSONPath : "storageKind" ,
1496+ EnumName : "CategoryKind" ,
1497+ },
1498+ },
1499+ },
1500+ },
1501+ },
1502+ },
1503+ },
1504+ },
1505+ },
1506+ Response : RPCMessage {
1507+ Name : "RequireStorageKindSummaryByIdResponse" ,
1508+ Fields : []RPCField {
1509+ {
1510+ Name : "result" ,
1511+ ProtoTypeName : DataTypeMessage ,
1512+ Repeated : true ,
1513+ JSONPath : "result" ,
1514+ Message : & RPCMessage {
1515+ Name : "RequireStorageKindSummaryByIdResult" ,
1516+ Fields : RPCFields {
1517+ {
1518+ Name : "kind_summary" ,
1519+ ProtoTypeName : DataTypeString ,
1520+ JSONPath : "kindSummary" ,
1521+ },
1522+ },
1523+ },
1524+ },
1525+ },
1526+ },
1527+ },
1528+ },
1529+ },
1530+ },
1531+ {
1532+ name : "requires with nested enum in type" ,
1533+ query : `query EntityLookup($representations: [_Any!]!) { _entities(representations: $representations) { ... on Storage { __typename name categoryInfoSummary } } }` ,
1534+ mapping : testMapping (),
1535+ federationConfigs : plan.FederationFieldConfigurations {
1536+ {
1537+ TypeName : "Storage" ,
1538+ SelectionSet : "id" ,
1539+ },
1540+ {
1541+ TypeName : "Storage" ,
1542+ FieldName : "categoryInfoSummary" ,
1543+ SelectionSet : "categoryInfo { kind name }" ,
1544+ },
1545+ },
1546+ expectedPlan : & RPCExecutionPlan {
1547+ Calls : []RPCCall {
1548+ {
1549+ ServiceName : "Products" ,
1550+ MethodName : "LookupStorageById" ,
1551+ Kind : CallKindEntity ,
1552+ Request : RPCMessage {
1553+ Name : "LookupStorageByIdRequest" ,
1554+ Fields : []RPCField {
1555+ {
1556+ Name : "keys" ,
1557+ ProtoTypeName : DataTypeMessage ,
1558+ Repeated : true ,
1559+ JSONPath : "representations" ,
1560+ Message : & RPCMessage {
1561+ Name : "LookupStorageByIdRequestKey" ,
1562+ MemberTypes : []string {"Storage" },
1563+ Fields : []RPCField {
1564+ {
1565+ Name : "id" ,
1566+ ProtoTypeName : DataTypeString ,
1567+ JSONPath : "id" ,
1568+ },
1569+ },
1570+ },
1571+ },
1572+ },
1573+ },
1574+ Response : RPCMessage {
1575+ Name : "LookupStorageByIdResponse" ,
1576+ Fields : []RPCField {
1577+ {
1578+ Name : "result" ,
1579+ ProtoTypeName : DataTypeMessage ,
1580+ Repeated : true ,
1581+ JSONPath : "_entities" ,
1582+ Message : & RPCMessage {
1583+ Name : "Storage" ,
1584+ Fields : []RPCField {
1585+ {
1586+ Name : "__typename" ,
1587+ ProtoTypeName : DataTypeString ,
1588+ JSONPath : "__typename" ,
1589+ StaticValue : "Storage" ,
1590+ },
1591+ {
1592+ Name : "name" ,
1593+ ProtoTypeName : DataTypeString ,
1594+ JSONPath : "name" ,
1595+ },
1596+ },
1597+ },
1598+ },
1599+ },
1600+ },
1601+ },
1602+ {
1603+ ID : 1 ,
1604+ ServiceName : "Products" ,
1605+ Kind : CallKindRequired ,
1606+ MethodName : "RequireStorageCategoryInfoSummaryById" ,
1607+ ResponsePath : buildPath ("_entities.categoryInfoSummary" ),
1608+ Request : RPCMessage {
1609+ Name : "RequireStorageCategoryInfoSummaryByIdRequest" ,
1610+ Fields : []RPCField {
1611+ {
1612+ Name : "context" ,
1613+ ProtoTypeName : DataTypeMessage ,
1614+ Repeated : true ,
1615+ JSONPath : "representations" ,
1616+ Message : & RPCMessage {
1617+ Name : "RequireStorageCategoryInfoSummaryByIdContext" ,
1618+ Fields : []RPCField {
1619+ {
1620+ Name : "key" ,
1621+ ProtoTypeName : DataTypeMessage ,
1622+ Message : & RPCMessage {
1623+ Name : "LookupStorageByIdRequestKey" ,
1624+ MemberTypes : []string {"Storage" },
1625+ Fields : []RPCField {
1626+ {
1627+ Name : "id" ,
1628+ ProtoTypeName : DataTypeString ,
1629+ JSONPath : "id" ,
1630+ },
1631+ },
1632+ },
1633+ },
1634+ {
1635+ Name : "fields" ,
1636+ ProtoTypeName : DataTypeMessage ,
1637+ Message : & RPCMessage {
1638+ Name : "RequireStorageCategoryInfoSummaryByIdFields" ,
1639+ Fields : []RPCField {
1640+ {
1641+ Name : "category_info" ,
1642+ ProtoTypeName : DataTypeMessage ,
1643+ JSONPath : "categoryInfo" ,
1644+ Message : & RPCMessage {
1645+ Name : "RequireStorageCategoryInfoSummaryByIdFields.StorageCategoryInfo" ,
1646+ Fields : []RPCField {
1647+ {
1648+ Name : "kind" ,
1649+ ProtoTypeName : DataTypeEnum ,
1650+ JSONPath : "kind" ,
1651+ EnumName : "CategoryKind" ,
1652+ },
1653+ {
1654+ Name : "name" ,
1655+ ProtoTypeName : DataTypeString ,
1656+ JSONPath : "name" ,
1657+ },
1658+ },
1659+ },
1660+ },
1661+ },
1662+ },
1663+ },
1664+ },
1665+ },
1666+ },
1667+ },
1668+ },
1669+ Response : RPCMessage {
1670+ Name : "RequireStorageCategoryInfoSummaryByIdResponse" ,
1671+ Fields : []RPCField {
1672+ {
1673+ Name : "result" ,
1674+ ProtoTypeName : DataTypeMessage ,
1675+ Repeated : true ,
1676+ JSONPath : "result" ,
1677+ Message : & RPCMessage {
1678+ Name : "RequireStorageCategoryInfoSummaryByIdResult" ,
1679+ Fields : RPCFields {
1680+ {
1681+ Name : "category_info_summary" ,
1682+ ProtoTypeName : DataTypeString ,
1683+ JSONPath : "categoryInfoSummary" ,
1684+ },
1685+ },
1686+ },
1687+ },
1688+ },
1689+ },
1690+ },
1691+ },
1692+ },
1693+ },
13831694 }
13841695
13851696 for _ , tt := range tests {
0 commit comments