atulmy / gql-query-builder

🔧 Simple GraphQL Query Builder
https://npmjs.com/package/gql-query-builder
MIT License
396 stars 43 forks source link

Custom mutation addapter type error when in strict mode #70

Open jgomesmv opened 2 years ago

jgomesmv commented 2 years ago

After creating a custom mutation adapter it throws an error when I pass it's type on mutation function. In order to check if the problem was related with my adapter code I tried to pass the default mutation adapter directly and the same error occurs.

Steps to reproduce:

  1. Setup an angular v13 solution (using typescript strict mode)
  2. Execute the mutation function passing DefaultMutationAdapter type as parameter
  3. The error is thrown: Argument of type 'typeof DefaultMutationAdapter' is not assignable to parameter of type 'IMutationAdapter'. Type 'typeof DefaultMutationAdapter' is missing the following properties from type 'IMutationAdapter': mutationBuilder, mutationsBuilder'. Type 'IMutationAdapter' is missing the following properties from type 'IMutationAdapter': mutationBuilder, mutationsBuilder

Example: ` import * as gql from 'gql-query-builder'; import DefaultMutationAdapter from 'gql-query-builder/build/adapters/DefaultMutationAdapter';

const query = gql.mutation({ operation: 'thoughtCreate', variables: { name: 'Tyrion Lannister', thought: 'I drink and I know things.' }, fields: ['id'] }, DefaultMutationAdapter);

console.log(query);

// Output mutation ($name: String, $thought: String) { thoughtCreate (name: $name, thought: $thought) { id } }

// Variables { "name": "Tyrion Lannister", "thought": "I drink and I know things." } `