Getting product specification in faststore v2

I need to fetch product specification information and product rules. To do this, I followed the API extension documentation.
I was using files with .tsx extension and there were no in the usePDP hook. I changed it to .ts as mentioned in the documentation and started receiving ‘GraphQL was not optimized and TS files were not updated. Changes in the GraphQL layer did not take effect.’
Details about each structure are attached in the PDF.
ApiExtension.pdf (92,7,KB)

Hi, Leonardo! How are you?

Based on your error message, you have to review the types, resolvers and fragments declared on the extension of your graphql layer, as per the image below:

Link: FastStore Documentation

I validated the code you sent attached and regarding the type defintion it seems fine. However I would change the resolver to the code below:

Also, in the fragment declaring, inside the customData, you have to return the fields that are part of the properties. It would look like something below:

Also please keep the resolver and the fragments files in the .ts extension. Don’t forget to export the resolver in the resolver/index.ts file.

After making your changes you can run the command yarn run faststore generate-graphql to see your changes being generated correctly.

If everything is running accordingly you will receive the following success message:

GraphQL schema, types, and optimizations successfully generated :tada:

I tested all the changes in a development mode (yarn dev) and they ran correctly.

Please let me know if you have any doubts, ok?

1 Like

Hi, Leonardo!

Just an update: after making the mentioned changes above, I ran my code locally generating the graphQL endpoint http://localhost:3000/api/graphql and by passing the field customData on the query I received correctly in the response the desired data:

This proves the code works fine.

But if you have any doubt about this topic or any other, please let me know, ok?