Apparent Error cors apollo-angular and .net with azure function

im developing my first cliet angular (v18) consuming an azure function app with graphql (hotcholate).

I have a problem with apollo apparently, when i try to consume the service, in the console.log of server i can see the consume to the azure function correctly and the return of data:

But in the client console its marks the next errors:

Additional i can’t see the data in my components, (im trying to show a list o products card) the list of products its ever empty.

I don’t know why it occurs; in my .net azure function i allow any origin. My code azure:

Startup.cs

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[assembly: FunctionsStartup(typeof(Startup))]
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.AddDatabase();
builder.Services.AddUseCases();
builder
.AddGraphQLFunction()
.AddQueryType<Query>();
// Configuración de CORS
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
}
}
</code>
<code>[assembly: FunctionsStartup(typeof(Startup))] public class Startup : FunctionsStartup { public override void Configure(IFunctionsHostBuilder builder) { builder.AddDatabase(); builder.Services.AddUseCases(); builder .AddGraphQLFunction() .AddQueryType<Query>(); // Configuración de CORS builder.Services.AddCors(options => { options.AddDefaultPolicy(builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); }); } } </code>
[assembly: FunctionsStartup(typeof(Startup))]

public class Startup : FunctionsStartup
{
  public override void Configure(IFunctionsHostBuilder builder)
  {
    builder.AddDatabase();
    builder.Services.AddUseCases();
    
    builder
        .AddGraphQLFunction()
        .AddQueryType<Query>();

    // Configuración de CORS
    builder.Services.AddCors(options =>
    {
        options.AddDefaultPolicy(builder =>
        {
            builder
                .AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
        });
    });
   }
 }

My client code:

graphql.provider.ts

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { Apollo, APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { ApplicationConfig, inject } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';
const uri = 'http://localhost:7071/api/graphql/';
export function apolloOptionsFactory(): ApolloClientOptions<any> {
const httpLink = inject(HttpLink);
return {
link: httpLink.create({ uri }),
cache: new InMemoryCache()
};
}
export const graphqlProvider: ApplicationConfig['providers'] = [
Apollo,
{
provide: APOLLO_OPTIONS,
useFactory: apolloOptionsFactory,
},
];
</code>
<code>import { Apollo, APOLLO_OPTIONS } from 'apollo-angular'; import { HttpLink } from 'apollo-angular/http'; import { ApplicationConfig, inject } from '@angular/core'; import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core'; const uri = 'http://localhost:7071/api/graphql/'; export function apolloOptionsFactory(): ApolloClientOptions<any> { const httpLink = inject(HttpLink); return { link: httpLink.create({ uri }), cache: new InMemoryCache() }; } export const graphqlProvider: ApplicationConfig['providers'] = [ Apollo, { provide: APOLLO_OPTIONS, useFactory: apolloOptionsFactory, }, ]; </code>
import { Apollo, APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLink } from 'apollo-angular/http';
import { ApplicationConfig, inject } from '@angular/core';
import { ApolloClientOptions, InMemoryCache } from '@apollo/client/core';

const uri = 'http://localhost:7071/api/graphql/'; 
export function apolloOptionsFactory(): ApolloClientOptions<any> {
const httpLink = inject(HttpLink);
 return {
  link: httpLink.create({ uri }),
   cache: new InMemoryCache()
 };
}

export const graphqlProvider: ApplicationConfig['providers'] = [
 Apollo,
 {
  provide: APOLLO_OPTIONS,
  useFactory: apolloOptionsFactory,
 },
];

product.service.ts

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { Injectable, computed, signal } from '@angular/core';
import { Product } from '@core/models/product';
import { Apollo, gql } from 'apollo-angular';
interface State{
products: Product[],
error: any,
loading: boolean
}
const GET_PRODUCTS = gql`
{
productsPaginated(first: 10, after: null){
nodes{
key
name
price
sale_price
ratings
},
edges{
cursor
}
pageInfo{
hasNextPage,
endCursor
}
totalCount
}
}
`;
@Injectable({
providedIn: 'root'
})
export class ProductsService {
#state = signal<State>({
loading:true,
products: [],
error: false
});
public productsGet = computed(()=> this.#state().products);
public productsErrGet = computed(()=> this.#state().error);
constructor(private apollo : Apollo) {
this.apollo.watchQuery({
query: GET_PRODUCTS
}).valueChanges.subscribe(({data, error} : any) => {
console.log(data.productsPaginated.nodes);
const products = data.productsPaginated.nodes.map((val: any): Product => ({
key: val.key,
name: val.name,
price: val.price,
sale_price : val.sale_price,
ratings: val.ratings
}));
this.#state.set({
loading:false,
products: products,
error: error
});
})
}
}
</code>
<code>import { Injectable, computed, signal } from '@angular/core'; import { Product } from '@core/models/product'; import { Apollo, gql } from 'apollo-angular'; interface State{ products: Product[], error: any, loading: boolean } const GET_PRODUCTS = gql` { productsPaginated(first: 10, after: null){ nodes{ key name price sale_price ratings }, edges{ cursor } pageInfo{ hasNextPage, endCursor } totalCount } } `; @Injectable({ providedIn: 'root' }) export class ProductsService { #state = signal<State>({ loading:true, products: [], error: false }); public productsGet = computed(()=> this.#state().products); public productsErrGet = computed(()=> this.#state().error); constructor(private apollo : Apollo) { this.apollo.watchQuery({ query: GET_PRODUCTS }).valueChanges.subscribe(({data, error} : any) => { console.log(data.productsPaginated.nodes); const products = data.productsPaginated.nodes.map((val: any): Product => ({ key: val.key, name: val.name, price: val.price, sale_price : val.sale_price, ratings: val.ratings })); this.#state.set({ loading:false, products: products, error: error }); }) } } </code>
import { Injectable, computed, signal } from '@angular/core';
import { Product } from '@core/models/product';
import { Apollo, gql } from 'apollo-angular';

interface State{
  products: Product[],
  error: any,
 loading: boolean
}

const GET_PRODUCTS = gql`
{
  productsPaginated(first: 10, after: null){
    nodes{
        key
        name
        price
        sale_price
        ratings
    },
    edges{
        cursor
    }
    pageInfo{
        hasNextPage,
        endCursor
    }
    totalCount
  }
 }
`;

@Injectable({
  providedIn: 'root'
})

export class ProductsService {
  #state = signal<State>({
    loading:true,
    products: [],
    error: false
});

public productsGet = computed(()=> this.#state().products);
public productsErrGet = computed(()=> this.#state().error);

constructor(private apollo : Apollo) {
  this.apollo.watchQuery({
   query: GET_PRODUCTS
  }).valueChanges.subscribe(({data, error} : any) => {

  console.log(data.productsPaginated.nodes);

  const products = data.productsPaginated.nodes.map((val: any): Product => ({
    key: val.key,
    name: val.name,
    price: val.price,
    sale_price : val.sale_price,
    ratings: val.ratings
  }));

    this.#state.set({
     loading:false,
     products: products,
     error: error
    });

  })
 }
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật