mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-11-04 09:57:41 +03:00 
			
		
		
		
	Added UpgradeGuide
This commit is contained in:
		
							parent
							
								
									a9e09dcee8
								
							
						
					
					
						commit
						01ddc83c4b
					
				| 
						 | 
				
			
			@ -25,6 +25,10 @@ pip install graphene[django]
 | 
			
		|||
pip install graphene[sqlalchemy]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 1.0 Upgrade Guide
 | 
			
		||||
 | 
			
		||||
Please read [UPGRADE-v1.0.md](/UPGRADE-v1.0.md) to learn how to upgrade.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Examples
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										66
									
								
								UPGRADE-v1.0.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								UPGRADE-v1.0.md
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,66 @@
 | 
			
		|||
# v1.0 Upgrade Guide
 | 
			
		||||
 | 
			
		||||
Big changes from v0.10.x to 1.0. While on the surface a lot of this just looks like shuffling around API, the entire codebase has been rewritten to handle some really great use cases and improved performance.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Backwards Compatibility and Deprecation Warnings
 | 
			
		||||
 | 
			
		||||
This has been a community project from the start, we need your help making the upgrade as smooth as possible for everybody!
 | 
			
		||||
We have done our best to provide backwards compatibility with deprecated APIs.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Interfaces
 | 
			
		||||
 | 
			
		||||
For implementing an Interface in a ObjectType, you have to add also `ObjectType`.
 | 
			
		||||
 | 
			
		||||
Like:
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
from graphene import Interface, ObjectType, String
 | 
			
		||||
 | 
			
		||||
class Character(Interface):
 | 
			
		||||
    name = String()
 | 
			
		||||
 | 
			
		||||
class Human(Character): # Old way, not working anymore
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class Droid(Character, ObjectType): # New way, you have to specify the ObjectType
 | 
			
		||||
    pass
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Mutations
 | 
			
		||||
 | 
			
		||||
Mutation fields have changed the way of usage, before if you have the mutation `MyMutation` you
 | 
			
		||||
only have to reference with `graphene.Field(MyMutation)` now it's simply `MyMutation.Field()`
 | 
			
		||||
 | 
			
		||||
Example:
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
from graphene import ObjectType, Mutation, String
 | 
			
		||||
 | 
			
		||||
class ReverseString(Mutation):
 | 
			
		||||
    class Input:
 | 
			
		||||
        input = String()
 | 
			
		||||
 | 
			
		||||
    reversed = String()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Query(ObjectType):
 | 
			
		||||
    reverse_string = graphene.Field(ReverseString) # Old way, not working anymore
 | 
			
		||||
    reverse_string = ReverseString.Field()
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Nodes
 | 
			
		||||
 | 
			
		||||
Apart of implementing as showed in the previous section, for use the node field you have to
 | 
			
		||||
specify the node Type.
 | 
			
		||||
 | 
			
		||||
Example:
 | 
			
		||||
 | 
			
		||||
```python
 | 
			
		||||
from graphene import ObjectType, relay
 | 
			
		||||
 | 
			
		||||
class Query(ObjectType):
 | 
			
		||||
    node = relay.NodeField() # Old way, NodeField no longer exists
 | 
			
		||||
    node = relay.Node.Field() # New way
 | 
			
		||||
```
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user