Can we use both GraphQL and REST API in the same project?

0

I'm creating a mobile application and was thinking of using Amplify/AppSync to communicate with the backend from the app. However, we also have a lot of relational data and the backend isn't designed around GraphQL. Using GraphQL would be convenient in the mobile app, but not for other aspects.

So I was wondering if we can add both the REST API and the GraphQL API to the same project.

Thanks!

질문됨 3년 전6386회 조회
4개 답변
0

Yes, this is possible to do.

hsspain
답변함 3년 전
0

Yes you can use both APIs by amplify add api command. You have to answer the questions asked about API configurations while creating API. Then proceed with the command again and add another API (either API gateway - REST or Appsync - GraphQL one)

Shaista
답변함 2년 전
0

It is possible to have a mix of APIs (GraphQL and REST, for example) in a project and even to share data stores (such as databases) between the various API schema. Nevertheless, you should be aware of some of the complexities that you have to face with such a decision and compare it to the option to convert the clients of the REST APIs to use GraphQL.

GraphQL is prevalent in mobile development as you want to be efficient in the number of calls that you need to do to the backend to fetch data, in the screen size of presenting that data, and the power (CPU, battery life...) of the mobile device to execute it. You might claim that these issues are not relevant to other data system interfaces such as desktops and prefer to use a more traditional API such as REST to build the interface.

When developing with a GraphQL attitude, you define the objects you want to work with using the format of GraphQL schema. In contrast, in the REST attitude, you will use Database Schema or API defined in code using frameworks such as FastAPI or Spring. GraphQL is more flexible, and you can create "graph" objects with columns or attributes from different related entities, while in REST, you will have to perform this logic on the client-side after calling multiple API calls to fetch the data.

There is also a tendency to associate GraphQL with a NoSQL database such as DynamoDB or MongoDB, and REST APIs more with Relational databases, where you can define relations between the objects in the "graph" in the relational model of the DB. This is also a type of a mix that you want to avoid, as data replication between these different datastore types is hard to maintain.

Eventually, you want to query and update the same object in the same datastore, and have different schema or datastore will make it complicated to evolve and modify them in parallel.

MLGuy
답변함 2년 전
0

Yes, you can definitely use both AWS AppSync (GraphQL) and AWS API Gateway (REST API) in the same project. AWS provides various services that allow you to build different types of APIs based on your project's requirements.

AWS
답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠