1
+ use std:: { borrow:: Borrow , cell:: RefCell , collections:: HashMap , fmt:: Debug , hash:: Hash } ;
2
+
1
3
use crate :: {
2
4
ast:: { Arguments , Definition , Document , Field , Fragment , FragmentSpread , Selection , Type } ,
3
5
parser:: { SourcePosition , Spanning } ,
4
6
schema:: meta:: { Field as FieldType , MetaType } ,
5
7
validation:: { ValidatorContext , Visitor } ,
6
8
value:: ScalarValue ,
7
9
} ;
8
- use std:: { borrow:: Borrow , cell:: RefCell , collections:: HashMap , fmt:: Debug , hash:: Hash } ;
9
10
10
11
#[ derive( Debug ) ]
11
12
struct Conflict ( ConflictReason , Vec < SourcePosition > , Vec < SourcePosition > ) ;
@@ -741,7 +742,7 @@ mod tests {
741
742
executor:: Registry ,
742
743
schema:: meta:: MetaType ,
743
744
types:: {
744
- base:: GraphQLType ,
745
+ base:: { GraphQLType , GraphQLValue } ,
745
746
scalars:: { EmptyMutation , EmptySubscription , ID } ,
746
747
} ,
747
748
} ;
@@ -1380,9 +1381,6 @@ mod tests {
1380
1381
where
1381
1382
S : ScalarValue ,
1382
1383
{
1383
- type Context = ( ) ;
1384
- type TypeInfo = ( ) ;
1385
-
1386
1384
fn name ( _: & ( ) ) -> Option < & ' static str > {
1387
1385
Some ( "SomeBox" )
1388
1386
}
@@ -1401,13 +1399,22 @@ mod tests {
1401
1399
}
1402
1400
}
1403
1401
1404
- impl < S > GraphQLType < S > for StringBox
1402
+ impl < S > GraphQLValue < S > for SomeBox
1405
1403
where
1406
1404
S : ScalarValue ,
1407
1405
{
1408
1406
type Context = ( ) ;
1409
1407
type TypeInfo = ( ) ;
1410
1408
1409
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1410
+ <Self as GraphQLType >:: name ( info)
1411
+ }
1412
+ }
1413
+
1414
+ impl < S > GraphQLType < S > for StringBox
1415
+ where
1416
+ S : ScalarValue ,
1417
+ {
1411
1418
fn name ( _: & ( ) ) -> Option < & ' static str > {
1412
1419
Some ( "StringBox" )
1413
1420
}
@@ -1432,13 +1439,22 @@ mod tests {
1432
1439
}
1433
1440
}
1434
1441
1435
- impl < S > GraphQLType < S > for IntBox
1442
+ impl < S > GraphQLValue < S > for StringBox
1436
1443
where
1437
1444
S : ScalarValue ,
1438
1445
{
1439
1446
type Context = ( ) ;
1440
1447
type TypeInfo = ( ) ;
1441
1448
1449
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1450
+ <Self as GraphQLType >:: name ( info)
1451
+ }
1452
+ }
1453
+
1454
+ impl < S > GraphQLType < S > for IntBox
1455
+ where
1456
+ S : ScalarValue ,
1457
+ {
1442
1458
fn name ( _: & ( ) ) -> Option < & ' static str > {
1443
1459
Some ( "IntBox" )
1444
1460
}
@@ -1463,13 +1479,22 @@ mod tests {
1463
1479
}
1464
1480
}
1465
1481
1466
- impl < S > GraphQLType < S > for NonNullStringBox1
1482
+ impl < S > GraphQLValue < S > for IntBox
1467
1483
where
1468
1484
S : ScalarValue ,
1469
1485
{
1470
1486
type Context = ( ) ;
1471
1487
type TypeInfo = ( ) ;
1472
1488
1489
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1490
+ <Self as GraphQLType >:: name ( info)
1491
+ }
1492
+ }
1493
+
1494
+ impl < S > GraphQLType < S > for NonNullStringBox1
1495
+ where
1496
+ S : ScalarValue ,
1497
+ {
1473
1498
fn name ( _: & ( ) ) -> Option < & ' static str > {
1474
1499
Some ( "NonNullStringBox1" )
1475
1500
}
@@ -1484,13 +1509,22 @@ mod tests {
1484
1509
}
1485
1510
}
1486
1511
1487
- impl < S > GraphQLType < S > for NonNullStringBox1Impl
1512
+ impl < S > GraphQLValue < S > for NonNullStringBox1
1488
1513
where
1489
1514
S : ScalarValue ,
1490
1515
{
1491
1516
type Context = ( ) ;
1492
1517
type TypeInfo = ( ) ;
1493
1518
1519
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1520
+ <Self as GraphQLType >:: name ( info)
1521
+ }
1522
+ }
1523
+
1524
+ impl < S > GraphQLType < S > for NonNullStringBox1Impl
1525
+ where
1526
+ S : ScalarValue ,
1527
+ {
1494
1528
fn name ( _: & ( ) ) -> Option < & ' static str > {
1495
1529
Some ( "NonNullStringBox1Impl" )
1496
1530
}
@@ -1515,13 +1549,22 @@ mod tests {
1515
1549
}
1516
1550
}
1517
1551
1518
- impl < S > GraphQLType < S > for NonNullStringBox2
1552
+ impl < S > GraphQLValue < S > for NonNullStringBox1Impl
1519
1553
where
1520
1554
S : ScalarValue ,
1521
1555
{
1522
1556
type Context = ( ) ;
1523
1557
type TypeInfo = ( ) ;
1524
1558
1559
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1560
+ <Self as GraphQLType >:: name ( info)
1561
+ }
1562
+ }
1563
+
1564
+ impl < S > GraphQLType < S > for NonNullStringBox2
1565
+ where
1566
+ S : ScalarValue ,
1567
+ {
1525
1568
fn name ( _: & ( ) ) -> Option < & ' static str > {
1526
1569
Some ( "NonNullStringBox2" )
1527
1570
}
@@ -1536,13 +1579,22 @@ mod tests {
1536
1579
}
1537
1580
}
1538
1581
1539
- impl < S > GraphQLType < S > for NonNullStringBox2Impl
1582
+ impl < S > GraphQLValue < S > for NonNullStringBox2
1540
1583
where
1541
1584
S : ScalarValue ,
1542
1585
{
1543
1586
type Context = ( ) ;
1544
1587
type TypeInfo = ( ) ;
1545
1588
1589
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1590
+ <Self as GraphQLType >:: name ( info)
1591
+ }
1592
+ }
1593
+
1594
+ impl < S > GraphQLType < S > for NonNullStringBox2Impl
1595
+ where
1596
+ S : ScalarValue ,
1597
+ {
1546
1598
fn name ( _: & ( ) ) -> Option < & ' static str > {
1547
1599
Some ( "NonNullStringBox2Impl" )
1548
1600
}
@@ -1567,13 +1619,22 @@ mod tests {
1567
1619
}
1568
1620
}
1569
1621
1570
- impl < S > GraphQLType < S > for Node
1622
+ impl < S > GraphQLValue < S > for NonNullStringBox2Impl
1571
1623
where
1572
1624
S : ScalarValue ,
1573
1625
{
1574
1626
type Context = ( ) ;
1575
1627
type TypeInfo = ( ) ;
1576
1628
1629
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1630
+ <Self as GraphQLType >:: name ( info)
1631
+ }
1632
+ }
1633
+
1634
+ impl < S > GraphQLType < S > for Node
1635
+ where
1636
+ S : ScalarValue ,
1637
+ {
1577
1638
fn name ( _: & ( ) ) -> Option < & ' static str > {
1578
1639
Some ( "Node" )
1579
1640
}
@@ -1591,13 +1652,22 @@ mod tests {
1591
1652
}
1592
1653
}
1593
1654
1594
- impl < S > GraphQLType < S > for Edge
1655
+ impl < S > GraphQLValue < S > for Node
1595
1656
where
1596
1657
S : ScalarValue ,
1597
1658
{
1598
1659
type Context = ( ) ;
1599
1660
type TypeInfo = ( ) ;
1600
1661
1662
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1663
+ <Self as GraphQLType >:: name ( info)
1664
+ }
1665
+ }
1666
+
1667
+ impl < S > GraphQLType < S > for Edge
1668
+ where
1669
+ S : ScalarValue ,
1670
+ {
1601
1671
fn name ( _: & ( ) ) -> Option < & ' static str > {
1602
1672
Some ( "Edge" )
1603
1673
}
@@ -1612,13 +1682,22 @@ mod tests {
1612
1682
}
1613
1683
}
1614
1684
1615
- impl < S > GraphQLType < S > for Connection
1685
+ impl < S > GraphQLValue < S > for Edge
1616
1686
where
1617
1687
S : ScalarValue ,
1618
1688
{
1619
1689
type Context = ( ) ;
1620
1690
type TypeInfo = ( ) ;
1621
1691
1692
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1693
+ <Self as GraphQLType >:: name ( info)
1694
+ }
1695
+ }
1696
+
1697
+ impl < S > GraphQLType < S > for Connection
1698
+ where
1699
+ S : ScalarValue ,
1700
+ {
1622
1701
fn name ( _: & ( ) ) -> Option < & ' static str > {
1623
1702
Some ( "Connection" )
1624
1703
}
@@ -1633,13 +1712,22 @@ mod tests {
1633
1712
}
1634
1713
}
1635
1714
1636
- impl < S > GraphQLType < S > for QueryRoot
1715
+ impl < S > GraphQLValue < S > for Connection
1637
1716
where
1638
1717
S : ScalarValue ,
1639
1718
{
1640
1719
type Context = ( ) ;
1641
1720
type TypeInfo = ( ) ;
1642
1721
1722
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1723
+ <Self as GraphQLType >:: name ( info)
1724
+ }
1725
+ }
1726
+
1727
+ impl < S > GraphQLType < S > for QueryRoot
1728
+ where
1729
+ S : ScalarValue ,
1730
+ {
1643
1731
fn name ( _: & ( ) ) -> Option < & ' static str > {
1644
1732
Some ( "QueryRoot" )
1645
1733
}
@@ -1661,6 +1749,18 @@ mod tests {
1661
1749
}
1662
1750
}
1663
1751
1752
+ impl < S > GraphQLValue < S > for QueryRoot
1753
+ where
1754
+ S : ScalarValue ,
1755
+ {
1756
+ type Context = ( ) ;
1757
+ type TypeInfo = ( ) ;
1758
+
1759
+ fn type_name < ' i > ( & self , info : & ' i Self :: TypeInfo ) -> Option < & ' i str > {
1760
+ <Self as GraphQLType >:: name ( info)
1761
+ }
1762
+ }
1763
+
1664
1764
#[ test]
1665
1765
fn conflicting_return_types_which_potentially_overlap ( ) {
1666
1766
expect_fails_rule_with_schema :: < _ , EmptyMutation < ( ) > , _ , _ , DefaultScalarValue > (
0 commit comments