Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Add GraphQL API to update the mutated short links #239

Open
andyyaldoo opened this issue Oct 13, 2019 · 13 comments
Open

Add GraphQL API to update the mutated short links #239

andyyaldoo opened this issue Oct 13, 2019 · 13 comments
Assignees
Labels
design-doc Write a design doc for a feature enhancement New feature or request Go Issue requires to write code using Go language good first issue Good for newcomers

Comments

@andyyaldoo
Copy link

From #237

@magicoder10 magicoder10 added the enhancement New feature or request label Oct 13, 2019
@magicoder10 magicoder10 added this to the alpha milestone Oct 13, 2019
@magicoder10 magicoder10 removed this from the Alpha milestone Jan 28, 2020
@magicoder10 magicoder10 added the design-doc Write a design doc for a feature label Mar 6, 2020
@alldroll alldroll added the Go Issue requires to write code using Go language label Mar 6, 2020
@oatovar
Copy link
Collaborator

oatovar commented Mar 23, 2020

I can take on this issue, and update everyone this Friday regarding the progress made.

@oatovar
Copy link
Collaborator

oatovar commented Mar 29, 2020

Required Steps

  1. Propose GraphQL API schema changes
  2. Add urlupdater.go and urlupdater_test.go to the usecases url package.
  3. Add approved changes to GraphQL API schema and resolvers.
  4. Update wire.go for dependency injection.
  5. Integrate the update shortlink api with the frontend.
  6. Toogle to true within the feature toggle

@oatovar
Copy link
Collaborator

oatovar commented Mar 30, 2020

GraphQL Schema

type AuthMutation {
    createURL(url: URLInput!, isPublic: Boolean!): URL
    updateURL(alias: String!, url: URLInput!): URL
    deleteURL(alias: String!)
}

@magicoder10
Copy link
Member

@oatovar Looks great to me!

For your information, we may consider combining all operations on urls to a single place. Maybe still keep the separate interfaces. Not sure what to do yet. The goal is to reduce unnecessary complexities.

@magicoder10 magicoder10 added this to the 3/28 - 04/03 milestone Mar 31, 2020
@oatovar
Copy link
Collaborator

oatovar commented Apr 1, 2020

@byliuyang Definitely understandable, making this flexible enough for future additions takes time.

@oatovar
Copy link
Collaborator

oatovar commented Apr 14, 2020

@byliuyang Should the user have the ability to mutate the short alias as well as the long link?

@magicoder10
Copy link
Member

@oatovar I think so.

@magicoder10
Copy link
Member

@oatovar It's seems that Facebook officially used only one input type: https://graphql.org/graphql-js/mutations-and-input-types/

@oatovar
Copy link
Collaborator

oatovar commented May 18, 2020

@byliuyang Thank you for the referenced example! In the example, the application doesn't verify if the content and author is ommited since the arugments are optional. In Short's case, the original url is always required during creation, so having one input where it's both optional for both creation and mutation would be misleading when using the schema. We could have one single input type where all fields are optional and enforce requirements in the implemenation, but it might lead to confusion down the road.

So far these are the two solutions with their tradeoffs:

Solution Pros Cons
One Input Reusability and simplicity Schema might cause confusion as to what arguments are required for each use case
Two Inputs Explicit attribute requirements Future addition to one input type would require modification of two input types the update input and creation input.

After going over the tradeoffs, I think that one input might be the better option at this time. The chances of causing confusion will be very low if the error handling explicitly describe failure reasons as it is now. However, I am open to either option and the changes required to update the current work on this feature will be very little regardless of the option taken. What are your thoughts?

@magicoder10
Copy link
Member

@oatovar It's a hard a decision. We can go with 1 input for now and look back in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
design-doc Write a design doc for a feature enhancement New feature or request Go Issue requires to write code using Go language good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants