queryUrl method

  1. @override
Uri queryUrl(
  1. String query, {
  2. Map<String, dynamic>? params,
})
override

Builds a URL for a GROQ query.

Implementation

@override
Uri queryUrl(String query, {Map<String, dynamic>? params}) {
  final queryParameters = <String, dynamic>{
    'query': query,
    'explain': config.explainQuery.toString(),
    'perspective': config.perspective.name,
    if (params != null) ...params,
  };

  return Uri(
    scheme: 'https',
    host: '${config.projectId}.${config.useCdn ? 'apicdn' : 'api'}.sanity.io',
    path: '/${config.apiVersion}/data/query/${config.dataset}',
    queryParameters: queryParameters,
  );
}