wrap-cli icon indicating copy to clipboard operation
wrap-cli copied to clipboard

Union Types Support

Open namesty opened this issue 2 years ago • 0 comments

Closes #246. This PR adds support for Union Types.

In order to pass a union argument, it has to comply with the following interface:

{
  type: string,
  value: $unionValue
}

Where type is the name of the union member type and value is the actual value.

Example:

Schema:


type ObjA {
  prop: String!
}

type ObjB {
  propB: [String!]!
}

type Union = ObjA | ObjB

Query {
 foo(arg: Union): Boolean!
}

Client:

await client.query({
      uri: ensUri,
      query: `
        query {
          foo(
            arg: $arg
          )
        }
      `,
      variables: {
        arg: {
          type: "ObjA",
          value: {  prop: "bar"  },
        }
      }
    });

namesty avatar Oct 22 '21 05:10 namesty