This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphQLClient _client = graphQLConfiguration.clientToQuery(); | |
QueryResult result = await _client.mutate( | |
MutationOptions( | |
document: addMutation.register('$_email','','$_password'), | |
), | |
); | |
if (result.data["success"]!=null){ | |
print('The user was created successfully!'); | |
}else{ | |
print('There was an error!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphQLConfiguration graphQLConfiguration = GraphQLConfiguration(); | |
QueryMutation addMutation = QueryMutation(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
WidgetsFlutterBinding.ensureInitialized(); | |
runApp( GraphQLProvider( | |
client: graphQLConfiguration.client, | |
child: CacheProvider(child: MyApp()), | |
),); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "package:graphql_flutter/graphql_flutter.dart"; | |
import 'graphQLConf.dart'; | |
import 'queryMutation.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auth.schema.py | |
import graphene | |
from graphql_auth.schema import UserQuery, MeQuery | |
from graphql_auth import mutations | |
class AuthMutation(graphene.ObjectType): | |
register = mutations.Register.Field() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings.py | |
INSTALLED_APPS = [ | |
# ... | |
"graphql_auth", | |
] | |
AUTHENTICATION_BACKENDS = [ | |
# remove this | |
# "graphql_jwt.backends.JSONWebTokenBackend", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auth.settings.py | |
INSTALLED_APPS = [ | |
# ... | |
'django.contrib.staticfiles', # Required for GraphiQL | |
'graphene_django', | |
# refresh tokens are optional | |
'graphql_jwt.refresh_token.apps.RefreshTokenConfig', | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auth.urls.py | |
from django.urls import path | |
from django.views.decorators.csrf import csrf_exempt | |
from graphene_django.views import GraphQLView | |
urlpatterns = [ | |
# ... | |
path("graphql", csrf_exempt(GraphQLView.as_view(graphiql=True))), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auth/settings.py | |
INSTALLED_APPS = [ | |
# ... | |
'users' | |
] | |
AUTH_USER_MODEL = 'users.CustomUser' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
from django.contrib.auth.models import AbstractUser | |
class CustomUser(AbstractUser): | |
EMAIL_FIELD = 'email' | |
USERNAME_FIELD = 'email' | |
REQUIRED_FIELDS = ['username'] | |
username= models.CharField(blank=True, max_length=254,) |
NewerOlder