-- Example Address: API surface (runs on the ods service). GRANT USAGE ON SCHEMA example_address TO anon; GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA example_address TO anon; GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA example_address TO anon; ALTER DEFAULT PRIVILEGES IN SCHEMA example_address GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO anon; -- The product's GraphQL endpoint: POST /rpc/example_address_graphql through PostgREST. -- pg_graphql reflects the schemas on the search_path, so the SET clause scopes the -- endpoint to this product's tables. CREATE FUNCTION api.example_address_graphql( query text, variables jsonb DEFAULT '{}'::jsonb, "operationName" text DEFAULT NULL, extensions jsonb DEFAULT NULL ) RETURNS jsonb LANGUAGE sql SECURITY INVOKER SET search_path = example_address, graphql AS $$ SELECT graphql.resolve(query, variables, "operationName", extensions); $$; GRANT EXECUTE ON FUNCTION api.example_address_graphql(text, jsonb, text, jsonb) TO anon; NOTIFY pgrst, 'reload schema';