From 67dedfaa700d709716fbdc8b26d3e7a4b847d9c0 Mon Sep 17 00:00:00 2001 From: kaioken Date: Mon, 5 Feb 2024 13:00:16 -0400 Subject: [PATCH] refact; countri filter --- graphql/schemas/Ecosystem/city.graphql | 5 +++-- graphql/schemas/Ecosystem/country.graphql | 14 ++++++-------- graphql/schemas/Ecosystem/states.graphql | 9 +++++++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/graphql/schemas/Ecosystem/city.graphql b/graphql/schemas/Ecosystem/city.graphql index c823fe39b..ad70d5f77 100644 --- a/graphql/schemas/Ecosystem/city.graphql +++ b/graphql/schemas/Ecosystem/city.graphql @@ -1,6 +1,6 @@ extend type Query { cities( - orderBy: _ @orderBy(columns: ["id", "created_at"]) + orderBy: _ @orderBy(columns: ["id", "created_at", "name"]) where: _ @whereConditions( columns: [ @@ -12,7 +12,8 @@ extend type Query { "country_id" ] ) - ): [Cities!]! @paginate(model: "Kanvas\\Locations\\Models\\Cities") + ): [Cities!]! + @paginate(defaultCount: 25, model: "Kanvas\\Locations\\Models\\Cities") city(id: Int!): Cities @find(model: "Kanvas\\Locations\\Models\\Cities") } diff --git a/graphql/schemas/Ecosystem/country.graphql b/graphql/schemas/Ecosystem/country.graphql index ac769f06a..eb27acac8 100644 --- a/graphql/schemas/Ecosystem/country.graphql +++ b/graphql/schemas/Ecosystem/country.graphql @@ -27,12 +27,15 @@ type Cities { extend type Query { countries( - orderBy: _ @orderBy(columns: ["id", "created_at"]) + orderBy: _ @orderBy(columns: ["id", "created_at", "name"]) where: _ @whereConditions(columns: ["name", "code", "flag", "id"]) hasStates: _ @whereHasConditions(columns: ["name"]) hasCities: _ @whereHasConditions(columns: ["name"]) ): [Country!]! - @paginate(model: "\\Kanvas\\Locations\\Models\\Countries") + @paginate( + defaultCount: 25 + model: "\\Kanvas\\Locations\\Models\\Countries" + ) country(id: Int! @eq): Country @find(model: "\\Kanvas\\Locations\\Models\\Countries") } @@ -64,12 +67,7 @@ extend type Mutation { @field( resolver: "App\\GraphQL\\Ecosystem\\Mutations\\Locations\\CreateCountry" ) - updateCountry( - id: ID! - name: String! - code: String! - flag: String - ): Country + updateCountry(id: ID!, name: String!, code: String!, flag: String): Country @update(model: "\\Kanvas\\Locations\\Models\\Countries") deleteCountry(id: ID!): Country! @delete(model: "\\Kanvas\\Locations\\Models\\Countries") diff --git a/graphql/schemas/Ecosystem/states.graphql b/graphql/schemas/Ecosystem/states.graphql index 7275bb197..b695ac2ed 100644 --- a/graphql/schemas/Ecosystem/states.graphql +++ b/graphql/schemas/Ecosystem/states.graphql @@ -5,8 +5,13 @@ type StateInput { } extend type Query { states( - where: _ @whereConditions(columns: ["name", "code", "id"]) - ): [States!]! @paginate(model: "\\Kanvas\\Locations\\Models\\States") + where: _ + @whereConditions(columns: ["name", "code", "id", "countries_id"]) + ): [States!]! + @paginate( + defaultCount: 25 + model: "\\Kanvas\\Locations\\Models\\States" + ) state(id: Int!): States @find(model: "\\Kanvas\\Locations\\Models\\States") }