2

Is the SerializerMutation suppose to convert ID! from base64 to a pk? Is there some frontend/backend helper util to assist in conversion? I haven't been able to find anything specific.

Example create thing mutation:

class CreateThingMutation(SerializerMutation):
    @classmethod
    def get_serializer_kwargs(cls, root, info, **input):
        import pdb;pdb.set_trace()
        return None

    @classmethod
    def mutate_and_get_payload(cls, root, info, text, id):
        import pdb;pdb.set_trace()
        return None

    class Meta:
        serializer_class = ThingListViewSerializer

Example query:

  mutation TestCreate($input: CreateThingMutationInput!) {
    createThing(input: $input) {
      item {
          id
      }
    }
  }

Example ID!:

item.id === atob('VW5pdE5vZGU6MjA=') === "UnitNode:20"

Edit, I was failing to convert the ID all the way so i had "20", just converted the type:

Number(atob(item.id).split(':')[1])

Question still remains about if there are any utility tools to automagically convert data being submitted to a mutation.

jmunsch
  • 22,771
  • 11
  • 93
  • 114

0 Answers0