Skip to content

Commit

Permalink
remove unnecessary args
Browse files Browse the repository at this point in the history
  • Loading branch information
dolevf committed Mar 25, 2022
1 parent a325d76 commit 88e4278
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions core/directives.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from unicodedata import name
from graphql import GraphQLArgument, GraphQLNonNull, GraphQLString
from graphql.type.directives import GraphQLDirective, DirectiveLocation
from graphql.type.directives import GraphQLDirective, DirectiveLocation, GraphQLDeprecatedDirective, GraphQLSkipDirective

GraphQLNetworkDirective = GraphQLDirective(
ShowNetworkDirective = GraphQLDirective(
name="show_network",
locations=[
DirectiveLocation.FIELD,
Expand All @@ -17,3 +17,5 @@
description="Displays the network associated with an IP Address (CIDR or Net)."
)

DeprecatedDirective = GraphQLDeprecatedDirective
SkipDirective = GraphQLSkipDirective
16 changes: 8 additions & 8 deletions core/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import graphene

from core.directives import GraphQLNetworkDirective
from core.directives import *
from db.solutions import solutions as list_of_solutions

from flask import (
Expand Down Expand Up @@ -55,11 +55,7 @@ class Meta:
model = Owner

class CreatePaste(graphene.Mutation):
title = graphene.String()
content = graphene.String()
public = graphene.Boolean()
paste = graphene.Field(lambda:PasteObject)
burn = graphene.Boolean()

class Arguments:
title = graphene.String()
Expand Down Expand Up @@ -157,7 +153,7 @@ class Mutations(graphene.ObjectType):

class Query(graphene.ObjectType):
pastes = graphene.List(PasteObject, public=graphene.Boolean(), limit=graphene.Int())
paste = graphene.Field(PasteObject, id=graphene.Int())
paste = graphene.Field(PasteObject, id=graphene.Int(), title=graphene.String())
system_update = graphene.String()
system_diagnostics = graphene.String(username=graphene.String(), password=graphene.String(), cmd=graphene.String())
system_health = graphene.String()
Expand All @@ -168,10 +164,14 @@ def resolve_pastes(self, info, public=False, limit=1000):
Audit.create_audit_entry(info)
return query.filter_by(public=public, burn=False).order_by(Paste.id.desc()).limit(limit)

def resolve_paste(self, info, id):
def resolve_paste(self, info, id=None, title=None):
query = PasteObject.get_query(info)
Audit.create_audit_entry(info)
if title:
return query.filter_by(title=title, burn=False).first()

return query.filter_by(id=id, burn=False).first()


def resolve_system_update(self, info):
security.simulate_load()
Expand Down Expand Up @@ -282,7 +282,7 @@ def set_difficulty():
if session.get('difficulty') == None:
helpers.set_mode('easy')

schema = graphene.Schema(query=Query, mutation=Mutations, directives=[GraphQLNetworkDirective])
schema = graphene.Schema(query=Query, mutation=Mutations, directives=[ShowNetworkDirective, SkipDirective, DeprecatedDirective])

gql_middlew = [
middleware.CostProtectionMiddleware(),
Expand Down

0 comments on commit 88e4278

Please sign in to comment.