Skip to content

GraphQLDate inputs cannot be delegated #106

Closed
@MarkPolivchuk

Description

If Service A has a mutation accepting a GraphQLDate input and it needs to delegate or forward that to another Service B with the same signature, the GraphQLDate yyyy-mm-dd string will be converted to a full DateTime string yyyy-mm-ddT00:00:00Z before arriving at Service B which fails validation.

For example, if the same mutation exists both in Service A and Service B, with A delegating the mutation to Service B:

Mutation {
  updateUser(input: UserInput!): User!
}

type User {
  id: ID!
  dob: GraphQLDate!
}

input UserInput {
  id: ID!
  dob: GraphQLDate!
}

And a client mutates Service A with the following

mutation updateUser($input: UserInput) {
  updateUser(input: $input) {
    id
    dob
  }
}

{
  "input": {
    "id": "1234",
    "dob": "2000-01-01"
  }
}

When service B receives the mutation, it will see the following as the input because it is being parsed to a JS Date object in service A:

{
  "input": {
    "id": "1234",
    "dob": "2000-01-01T00:00:00Z"
  }
}

Which fails validation.

You are already stripping the time component when serializing the GraphQL date. Can we do the same when parsing so that values can be passed from service to service?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions