Abfragen erstellen
Hier sind einige Beispiele, die Ihnen helfen, Ihre GraphQL-Abfragen zu erstellen.
Wichtige Hinweise zu Suchfunktionen
-
Für kombinierte Suchen (z. B. Name + PLZ,
Name + Stadt, + Spezialisierung)
empfehlen wir die per GraphQL exponierten Postgres-Funktionen
(z. B.
search_facilities) statt relationaler Filter. -
Funktionsargumente werden direkt übergeben.
Verwenden Sie kein
args: { ... }. -
Viele set-returning Funktionen werden als Connection
exponiert: Ergebnisse über
edges { node { ... } }abfragen. - Spezialiserungsfilter erwarten den kanonischen Slug (siehe Slugs & Synonyme).
Grundlegende Sammlungsabfrage
Rufen Sie die ersten 5 Professionals und deren Namen ab.
query GetProfessionals {
professionalsCollection(first: 5) {
edges {
node {
id
first_name
last_name
title
}
}
}
} Abfragen eines einzelnen Knotens nach ID
Rufen Sie einen bestimmten Professional anhand seiner ID ab.
Ersetzen Sie your-professional-id durch eine tatsächliche ID.
query GetProfessionalById {
professional(id: "your-professional-id") {
id
first_name
last_name
}
} Verwendung von Argumenten und Filtern
Filtern Sie Professionals nach Nachnamen. (Die vollständigen Filterfunktionen finden Sie in der pg_graphql-Dokumentation).
query FilterProfessionals {
professionalsCollection(filter: { last_name: { eq: "Mustermann" } }) {
edges {
node {
id
first_name
last_name
}
}
}
} Abfragen verschachtelter Daten
Rufen Sie Professionals und die zugehörigen Spezialisierungen ab.
query GetProfessionalsWithSpecialisations {
professionalsCollection(first: 2) {
edges {
node {
id
first_name
last_name
specialisationsCollection {
edges {
node {
specialisation {
id
name_de
}
}
}
}
}
}
}
} Verwendung von Variablen
Gestalten Sie Ihre Abfragen dynamisch mithilfe von Variablen.
Query
query GetProfessionalByLastName($lastName: String!) {
professionalsCollection(filter: { last_name: { eq: $lastName } }, first: 5) {
edges {
node {
id
first_name
last_name
}
}
}
} Variables
{
"lastName": "Schmidt"
} Suche nach LANR (Lebenslange Arztnummer)
In diesem Beispiel bauen wir Schritt für Schritt eine Abfrage, um eine Ärztin / einen Arzt anhand der LANR (Lebenslange Arztnummer) zu finden.
-
Wir verwenden die Tabelle
professional_idsCollection, in der verschiedene ID-Arten (z.B. LANR) gespeichert sind. -
In dieser Tabelle filtern wir auf
id_kindmit dem Enum-Wertlanr. -
Zusätzlich filtern wir auf
id_valuemit einer Variable$lanr, damit Sie die LANR dynamisch übergeben können. -
Über die Relation
professionalsholen wir das vollständige Profil der Fachkraft inklusive Spezialisierungen.
Ersetzen Sie den Beispielwert
"123456789" durch
die tatsächliche LANR, nach der Sie suchen möchten.
Query
query GetProfessionalByLanr($lanr: String!) {
professional_idsCollection(
first: 10
filter: {
id_kind: { eq: lanr } # Enum-Wert
id_value: { eq: $lanr } # String
}
) {
edges {
node {
professional_id
id_kind
id_value
professionals {
id
title
first_name
last_name
gender
languages
professional_specialisationsCollection {
edges {
node {
specialisation_id
specialisations {
slug
name_de
}
}
}
}
}
}
}
}
} Variables
{
"lanr": "123456789"
} Suche nach BSNR (Betriebsstättennummer)
In diesem Beispiel suchen wir eine Einrichtung anhand ihrer BSNR (Betriebsstättennummer).
-
Wir verwenden die Tabelle
facility_idsCollection, in der verschiedene Identifikatoren von Einrichtungen gespeichert sind (z. B. BSNR). -
In dieser Tabelle filtern wir auf
id_valuemit einer Variable$bsnr, damit Sie die BSNR dynamisch übergeben können. -
Über die Relation
facilitiesholen wir das zugehörige Einrichtungsprofil inklusive Standortdaten.
Ersetzen Sie den Beispielwert
"123456789" durch
die tatsächliche BSNR der Einrichtung, nach der Sie suchen
möchten.
Query
query GetFacilityByBsnr($bsnr: String!) {
facility_idsCollection(
first: 1
filter: { id_value: { eq: $bsnr } }
) {
edges {
node {
facility_id
id_value
facilities {
facility_type
name
website
email
phone
fax
location_id
locations {
id
street
zip_code
city
state
country
}
}
}
}
}
} Variables
{
"bsnr": "123456789"
} Client-Integration: Einrichtungsprofil (MVZ)
Diese Abfrage ruft ein umfassendes Profil für eine einzelne Einrichtung (z. B. ein medizinisches Versorgungszentrum oder "MVZ") unter Verwendung ihrer eindeutigen ID ab.
Kostenlose Einrichtungs-ID zum Testen: 5d86e14b-704e-4d4d-b851-40f7f0fee716
Query
query GetFacilityProfile($id: UUID!) {
facilitiesCollection(filter: { id: { eq: $id } }) {
edges {
node {
id
name
facility_type
website
email
phone
fax
only_private_patients
active
location: locations {
street
zip_code
city
state
country
wheelchair_accessible
latitude
longitude
}
opening_hoursCollection {
edges {
node {
weekday
open_time
close_time
notes
}
}
}
professional_facility_rolesCollection {
edges {
node {
role
contact_email
contact_phone
professional: professionals {
id
first_name
last_name
title
is_doctor
}
}
}
}
facilityIdsCollection {
edges {
node {
id_kind
id_value
}
}
}
}
}
}
} Response Preview
{
"data": {
"facilitiesCollection": {
"edges": [ { "node": { "id": "...", "name": "MVZ Musterstadt", "...": "..." } } ]
}
}
} Client-Integration: Profil einer Fachkraft (Arzt)
Diese Abfrage ruft ein umfassendes Profil für eine einzelne Fachkraft (z. B. einen Arzt) unter Verwendung ihrer eindeutigen ID ab.
Kostenlose Fachkraft-ID zum Testen: bf9e7cdb-2a18-4a18-b792-f577ef91b25c
Query
query GetProfessionalProfile($id: UUID!) {
professionalsCollection(filter: { id: { eq: $id } }) {
edges {
node {
id
first_name
last_name
title
gender
is_doctor
is_active
languages
professionalIdsCollection { edges { node { id_kind, id_value } } }
professional_specialisationsCollection {
edges {
node {
specialisation: specialisations {
name_de
name_en
synonyms_de
}
}
}
}
professional_facility_rolesCollection {
edges {
node {
role
contact_email
contact_phone
facility: facilities {
id
name
facility_type
website
location: locations {
street
zip_code
city
}
}
}
}
}
}
}
}
} Response Preview
{
"data": {
"professionalsCollection": {
"edges": [ { "node": { "id": "...", "last_name": "Musterfrau", "...": "..." } } ]
}
}
} Autocomplete / Typeahead (Einrichtungen)
Für Autocomplete/Typeahead empfehlen wir:
-
Kurzes Limit (typisch
5–10Ergebnisse) -
Möglichst minimale Felder (z. B.
id, Name und 1–2 Adressfelder), um Credits zu sparen -
Prefix-Matches (
"term%") für Typeahead, Contains-Matches ("%term%") wenn nötig - Client-seitiges Debouncing (z. B. 150–300ms)
Autocomplete: Einrichtungssuche nach Name (tabellenbasiert, minimal)
Liefert eine leichte Ergebnisliste für Dropdowns (id, Name, Typ und kurze Adresse).
Query
query SearchFacilitiesByName($pattern: String!, $limit: Int!) {
facilitiesCollection(
filter: { name: { ilike: $pattern } }
first: $limit
) {
edges {
node {
id
name
facility_type
location: locations {
street
zip_code
city
}
}
}
}
} Variables (Prefix match – empfohlen)
{
"pattern": "praxis%",
"limit": 10
} Variables (Contains match)
{
"pattern": "%zentrum%",
"limit": 10
} Autocomplete: Einrichtungssuche nach PLZ + Name (Funktion)
Empfohlen, wenn Sie PLZ und Name kombinieren. Nutzt eine GraphQL-exponierte Funktion und vermeidet relationale Filter, die in pg_graphql scheitern können.
Query
query SearchFacilitiesByZipAndName(
$zip: String!
$pattern: String!
$specialisationSlug: String
$limit: Int!
$offset: Int!
) {
search_facilities_by_zip_and_name(
p_zip_code: $zip
p_name_pattern: $pattern
p_specialisation_slug: $specialisationSlug
p_limit: $limit
p_offset: $offset
) {
edges {
node {
id
name
facility_type
locations {
street
zip_code
city
}
}
}
}
} Variables (Name + PLZ, ohne Spezialisierung)
{
"zip": "10115",
"pattern": "praxis%",
"specialisationSlug": null,
"limit": 10,
"offset": 0
} Variables (Name + PLZ + Spezialisierung)
{
"zip": "10115",
"pattern": "praxis%",
"specialisationSlug": "general-practice",
"limit": 10,
"offset": 0
} Autocomplete: Einrichtungssuche nach Stadt + Name (Funktion)
Empfohlen, wenn Sie nach Stadt und Name suchen (z. B. Praxis/MVZ-Suche). Unterstützt optional Spezialisierungsfilter.
Query
query SearchFacilitiesByCityAndName(
$cityPattern: String!
$pattern: String!
$specialisationSlug: String
$limit: Int!
$offset: Int!
) {
search_facilities_by_city_and_name(
p_city_pattern: $cityPattern
p_name_pattern: $pattern
p_specialisation_slug: $specialisationSlug
p_limit: $limit
p_offset: $offset
) {
edges {
node {
id
name
facility_type
locations {
street
zip_code
city
}
}
}
}
} Variables (Name + Stadt, ohne Spezialisierung)
{
"cityPattern": "münchen%",
"pattern": "mvz%",
"specialisationSlug": null,
"limit": 10,
"offset": 0
} Variables (Name + Stadt + Spezialisierung)
{
"cityPattern": "münchen%",
"pattern": "mvz%",
"specialisationSlug": "gynecology-obstetrics",
"limit": 10,
"offset": 0
} Empfohlen: eine flexible Einrichtungssuche (search_facilities)
Für neue Integrationen empfehlen wir eine einzige flexible Funktion, die Name + (optional) PLZ/Stadt + (optional) Spezialisierung unterstützt.
Query
query SearchFacilities(
$namePattern: String!
$zip: String
$cityPattern: String
$specialisationSlug: String
$limit: Int!
$offset: Int!
) {
search_facilities(
p_name_pattern: $namePattern
p_zip_code: $zip
p_city_pattern: $cityPattern
p_specialisation_slug: $specialisationSlug
p_limit: $limit
p_offset: $offset
) {
edges {
node {
id
name
facility_type
locations {
street
zip_code
city
}
}
}
}
} Variables (Name + PLZ)
{
"namePattern": "praxis%",
"zip": "10115",
"cityPattern": null,
"specialisationSlug": null,
"limit": 10,
"offset": 0
} Variables (Name + Stadt + Spezialisierung)
{
"namePattern": "%zentrum%",
"zip": null,
"cityPattern": "berlin%",
"specialisationSlug": "general-practice",
"limit": 10,
"offset": 0
} Suche nach Fachkräften (Funktion): PLZ/Stadt/Einrichtungsname + Spezialisierung
Nutzen Sie dies, wenn Nutzer Fachkräfte suchen möchten, die zu Ort und/oder Einrichtungsname und einer Spezialisierung passen.
Query
query SearchProfessionals(
$zip: String
$cityPattern: String
$facilityNamePattern: String
$specialisationSlug: String
$limit: Int!
$offset: Int!
) {
search_professionals(
p_zip_code: $zip
p_city_pattern: $cityPattern
p_facility_name_pattern: $facilityNamePattern
p_specialisation_slug: $specialisationSlug
p_limit: $limit
p_offset: $offset
) {
edges {
node {
id
first_name
last_name
title
gender
professional_specialisationsCollection {
edges {
node {
specialisations {
slug
name_de
}
}
}
}
professional_facility_rolesCollection {
edges {
node {
role
facilities {
id
name
locations {
zip_code
city
street
}
}
}
}
}
}
}
}
} Variables (PLZ + Spezialisierung)
{
"zip": "10115",
"cityPattern": null,
"facilityNamePattern": null,
"specialisationSlug": "general-practice",
"limit": 10,
"offset": 0
} Variables (Stadt + Einrichtungsname + Spezialisierung)
{
"zip": null,
"cityPattern": "berlin%",
"facilityNamePattern": "%praxis%",
"specialisationSlug": "gynecology-obstetrics",
"limit": 10,
"offset": 0
} Empfohlener Flow: Autocomplete → Details (best results + sparsam)
Typischer UX-Flow, um Autocomplete günstig zu halten, aber nach Auswahl ein vollständiges Profil zu laden:
- Während der Eingabe: Laden Sie 5–10 leichte Ergebnisse (nur Felder für Dropdown/Label).
- Nach Auswahl: Laden Sie das komplette Profil per ID.
Step A – Autocomplete via search_facilities (minimal)
query SearchFacilities($namePattern: String!, $limit: Int!, $offset: Int!) {
search_facilities(
p_name_pattern: $namePattern
p_zip_code: null
p_city_pattern: null
p_specialisation_slug: null
p_limit: $limit
p_offset: $offset
) {
edges {
node {
id
name
facility_type
locations {
street
zip_code
city
}
}
}
}
} Step B – Details by ID (vollständig)
query GetFacilityProfile($id: UUID!) {
facilitiesCollection(filter: { id: { eq: $id } }) {
edges {
node {
id
name
facility_type
website
email
phone
fax
only_private_patients
active
location: locations {
street
zip_code
city
state
country
wheelchair_accessible
latitude
longitude
}
opening_hoursCollection {
edges {
node {
weekday
open_time
close_time
notes
}
}
}
professional_facility_rolesCollection {
edges {
node {
role
contact_email
contact_phone
professional: professionals {
id
first_name
last_name
title
is_doctor
}
}
}
}
facilityIdsCollection {
edges {
node {
id_kind
id_value
}
}
}
}
}
}
}